From 93d9a044608c84fc8335f25269b1d5572c41b0e1 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 10 Dec 2024 20:57:10 +0800 Subject: [PATCH] enhance: show reverting commit in banner while reverting is in-progress --- src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/InProgressContexts.cs | 14 ++++++++++++-- src/ViewModels/WorkingCopy.cs | 22 ++++++++++++++++------ src/Views/Repository.axaml | 6 +++++- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 9673a65a..5bb61b9c 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -399,6 +399,7 @@ Rebase in progress. Stopped at Revert in progress. + Reverting commit Interactive Rebase Target Branch: On: diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 1f5a39d9..7a0bc47e 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -402,6 +402,7 @@ 变基(Rebase)操作进行中。 当前停止于 回滚提交操作进行中。 + 正在回滚提交 交互式变基 目标分支 : 起始提交 : diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 27a9b5e4..3ffbebc0 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -402,6 +402,7 @@ 重定基底 (rebase) 操作進行中。 当前停止于 復原提交操作進行中。 + 正在復原提交 互動式重定基底 目標分支: 起始提交: diff --git a/src/ViewModels/InProgressContexts.cs b/src/ViewModels/InProgressContexts.cs index bfa1a28a..ba095fb5 100644 --- a/src/ViewModels/InProgressContexts.cs +++ b/src/ViewModels/InProgressContexts.cs @@ -93,7 +93,7 @@ namespace SourceGit.ViewModels public CherryPickInProgress(Repository repo) : base(repo.FullPath, "cherry-pick", true) { var headSHA = File.ReadAllText(Path.Combine(repo.GitDir, "CHERRY_PICK_HEAD")).Trim(); - Head = new Commands.QuerySingleCommit(repo.FullPath, headSHA).Result(); + Head = new Commands.QuerySingleCommit(repo.FullPath, headSHA).Result() ?? new Models.Commit() { SHA = headSHA }; } } @@ -171,7 +171,17 @@ namespace SourceGit.ViewModels public class RevertInProgress : InProgressContext { - public RevertInProgress(Repository repo) : base(repo.FullPath, "revert", false) { } + public Models.Commit Head + { + get; + private set; + } + + public RevertInProgress(Repository repo) : base(repo.FullPath, "revert", false) + { + var headSHA = File.ReadAllText(Path.Combine(repo.GitDir, "REVERT_HEAD")).Trim(); + Head = new Commands.QuerySingleCommit(repo.FullPath, headSHA).Result() ?? new Models.Commit() { SHA = headSHA }; + } } public class MergeInProgress : InProgressContext diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 1c657d06..3c6add56 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -569,14 +569,19 @@ namespace SourceGit.ViewModels e.Handled = true; }; - if (_inProgressContext is RebaseInProgress rebase) + if (_inProgressContext is CherryPickInProgress cherryPick) + { + useTheirs.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", cherryPick.HeadName); + useMine.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", _repo.CurrentBranch.Name); + } + else if(_inProgressContext is RebaseInProgress rebase) { useTheirs.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", rebase.HeadName); useMine.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", rebase.BaseName); } - else if (_inProgressContext is CherryPickInProgress cherryPick) + else if (_inProgressContext is RevertInProgress revert) { - useTheirs.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", cherryPick.HeadName); + useTheirs.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", revert.Head.SHA.Substring(0, 10) + " (revert)"); useMine.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", _repo.CurrentBranch.Name); } else if (_inProgressContext is MergeInProgress merge) @@ -909,14 +914,19 @@ namespace SourceGit.ViewModels e.Handled = true; }; - if (_inProgressContext is RebaseInProgress rebase) + if (_inProgressContext is CherryPickInProgress cherryPick) + { + useTheirs.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", cherryPick.HeadName); + useMine.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", _repo.CurrentBranch.Name); + } + else if (_inProgressContext is RebaseInProgress rebase) { useTheirs.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", rebase.HeadName); useMine.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", rebase.BaseName); } - else if (_inProgressContext is CherryPickInProgress cherryPick) + else if (_inProgressContext is RevertInProgress revert) { - useTheirs.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", cherryPick.HeadName); + useTheirs.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", revert.Head.SHA.Substring(0,10) + " (revert)"); useMine.Header = new Views.NameHighlightedTextBlock("FileCM.ResolveUsing", _repo.CurrentBranch.Name); } else if (_inProgressContext is MergeInProgress merge) diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 0bfc26c7..24b58fa2 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -579,7 +579,11 @@ - + + + + +