Skip to content

Commit 5301645

Browse files
authored
fix: in commit view get file histories by commit (#708)
When file histories are accessed from the commit details view, run git log for the inspected commit. Previously the log was ran against current branch regardless whether the inspected commit belongs to that branch.
1 parent 882878d commit 5301645

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/ViewModels/CommitDetail.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public ContextMenu CreateChangeContextMenu(Models.Change change)
293293
history.Icon = App.CreateMenuIcon("Icons.Histories");
294294
history.Click += (_, ev) =>
295295
{
296-
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path) };
296+
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path, _commit.SHA) };
297297
window.Show();
298298
ev.Handled = true;
299299
};
@@ -434,7 +434,7 @@ public ContextMenu CreateRevisionFileContextMenu(Models.Object file)
434434
history.Icon = App.CreateMenuIcon("Icons.Histories");
435435
history.Click += (_, ev) =>
436436
{
437-
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path) };
437+
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path, _commit.SHA) };
438438
window.Show();
439439
ev.Handled = true;
440440
};

src/ViewModels/FileHistories.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public object ViewContent
5757
private set => SetProperty(ref _viewContent, value);
5858
}
5959

60-
public FileHistories(Repository repo, string file)
60+
public FileHistories(Repository repo, string file, string commit = null)
6161
{
6262
_repo = repo;
6363
_file = file;
6464

6565
Task.Run(() =>
6666
{
67-
var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 -- \"{file}\"", false).Result();
67+
var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 {commit} -- \"{file}\"", false).Result();
6868
Dispatcher.UIThread.Invoke(() =>
6969
{
7070
IsLoading = false;

0 commit comments

Comments
 (0)