enhance: show reverting commit in banner while reverting is in-progress

This commit is contained in:
leo 2024-12-10 20:57:10 +08:00
parent 2dd9cab695
commit 93d9a04460
No known key found for this signature in database
6 changed files with 36 additions and 9 deletions

View file

@ -399,6 +399,7 @@
<x:String x:Key="Text.InProgress.Rebase" xml:space="preserve">Rebase in progress.</x:String>
<x:String x:Key="Text.InProgress.Rebase.StoppedAt" xml:space="preserve">Stopped at</x:String>
<x:String x:Key="Text.InProgress.Revert" xml:space="preserve">Revert in progress.</x:String>
<x:String x:Key="Text.InProgress.Revert.Head" xml:space="preserve">Reverting commit</x:String>
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">Interactive Rebase</x:String>
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">Target Branch:</x:String>
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">On:</x:String>

View file

@ -402,6 +402,7 @@
<x:String x:Key="Text.InProgress.Rebase" xml:space="preserve">变基Rebase操作进行中。</x:String>
<x:String x:Key="Text.InProgress.Rebase.StoppedAt" xml:space="preserve">当前停止于</x:String>
<x:String x:Key="Text.InProgress.Revert" xml:space="preserve">回滚提交操作进行中。</x:String>
<x:String x:Key="Text.InProgress.Revert.Head" xml:space="preserve">正在回滚提交</x:String>
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">交互式变基</x:String>
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">目标分支 </x:String>
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">起始提交 </x:String>

View file

@ -402,6 +402,7 @@
<x:String x:Key="Text.InProgress.Rebase" xml:space="preserve">重定基底 (rebase) 操作進行中。</x:String>
<x:String x:Key="Text.InProgress.Rebase.StoppedAt" xml:space="preserve">当前停止于</x:String>
<x:String x:Key="Text.InProgress.Revert" xml:space="preserve">復原提交操作進行中。</x:String>
<x:String x:Key="Text.InProgress.Revert.Head" xml:space="preserve">正在復原提交</x:String>
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">互動式重定基底</x:String>
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">目標分支:</x:String>
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">起始提交:</x:String>

View file

@ -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

View file

@ -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)

View file

@ -579,7 +579,11 @@
</DataTemplate>
<DataTemplate DataType="vm:RevertInProgress">
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold" Foreground="{DynamicResource Brush.ConflictForeground}" Text="{DynamicResource Text.InProgress.Revert}"/>
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="{DynamicResource Brush.ConflictForeground}" Text="{DynamicResource Text.InProgress.Revert.Head}"/>
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="DarkOrange" Text="{Binding Head.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" ToolTip.Tip="{Binding Head}"/>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="vm:MergeInProgress">