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.
This commit is contained in:
Dmitrij D. Czarkoff 2024-11-17 03:14:56 +00:00 committed by GitHub
parent 882878dbe5
commit 5301645f8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -293,7 +293,7 @@ namespace SourceGit.ViewModels
history.Icon = App.CreateMenuIcon("Icons.Histories"); history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) => history.Click += (_, ev) =>
{ {
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path) }; var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path, _commit.SHA) };
window.Show(); window.Show();
ev.Handled = true; ev.Handled = true;
}; };
@ -434,7 +434,7 @@ namespace SourceGit.ViewModels
history.Icon = App.CreateMenuIcon("Icons.Histories"); history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) => history.Click += (_, ev) =>
{ {
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path) }; var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path, _commit.SHA) };
window.Show(); window.Show();
ev.Handled = true; ev.Handled = true;
}; };

View file

@ -57,14 +57,14 @@ namespace SourceGit.ViewModels
private set => SetProperty(ref _viewContent, value); private set => SetProperty(ref _viewContent, value);
} }
public FileHistories(Repository repo, string file) public FileHistories(Repository repo, string file, string commit = null)
{ {
_repo = repo; _repo = repo;
_file = file; _file = file;
Task.Run(() => Task.Run(() =>
{ {
var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 -- \"{file}\"", false).Result(); var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 {commit} -- \"{file}\"", false).Result();
Dispatcher.UIThread.Invoke(() => Dispatcher.UIThread.Invoke(() =>
{ {
IsLoading = false; IsLoading = false;