From 5301645f8bab7049710b7a9eaf10e2d62ad4fb7c Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Sun, 17 Nov 2024 03:14:56 +0000 Subject: [PATCH] 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. --- src/ViewModels/CommitDetail.cs | 4 ++-- src/ViewModels/FileHistories.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index ef060f04..7ef8ce85 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -293,7 +293,7 @@ namespace SourceGit.ViewModels history.Icon = App.CreateMenuIcon("Icons.Histories"); 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(); ev.Handled = true; }; @@ -434,7 +434,7 @@ namespace SourceGit.ViewModels history.Icon = App.CreateMenuIcon("Icons.Histories"); 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(); ev.Handled = true; }; diff --git a/src/ViewModels/FileHistories.cs b/src/ViewModels/FileHistories.cs index 035cadfd..52ed6b01 100644 --- a/src/ViewModels/FileHistories.cs +++ b/src/ViewModels/FileHistories.cs @@ -57,14 +57,14 @@ namespace SourceGit.ViewModels private set => SetProperty(ref _viewContent, value); } - public FileHistories(Repository repo, string file) + public FileHistories(Repository repo, string file, string commit = null) { _repo = repo; _file = file; 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(() => { IsLoading = false;