enhance: show friendly name instead of --theirs or --mine while resolving conflicts

This commit is contained in:
leo 2024-12-10 16:44:37 +08:00
parent c8cdda3477
commit feb7e96b2c
No known key found for this signature in database
5 changed files with 45 additions and 0 deletions

View file

@ -281,6 +281,7 @@
<x:String x:Key="Text.FileCM.DiscardMulti" xml:space="preserve">Discard {0} files...</x:String>
<x:String x:Key="Text.FileCM.DiscardSelectedLines" xml:space="preserve">Discard Changes in Selected Line(s)</x:String>
<x:String x:Key="Text.FileCM.OpenWithExternalMerger" xml:space="preserve">Open External Merge Tool</x:String>
<x:String x:Key="Text.FileCM.ResolveUsing" xml:space="preserve">Resolve Using '{0}'</x:String>
<x:String x:Key="Text.FileCM.SaveAsPatch" xml:space="preserve">Save as Patch...</x:String>
<x:String x:Key="Text.FileCM.Stage" xml:space="preserve">Stage</x:String>
<x:String x:Key="Text.FileCM.StageMulti" xml:space="preserve">Stage {0} files</x:String>

View file

@ -284,6 +284,7 @@
<x:String x:Key="Text.FileCM.DiscardMulti" xml:space="preserve">放弃 {0} 个文件的更改...</x:String>
<x:String x:Key="Text.FileCM.DiscardSelectedLines" xml:space="preserve">放弃选中的更改</x:String>
<x:String x:Key="Text.FileCM.OpenWithExternalMerger" xml:space="preserve">使用外部合并工具打开</x:String>
<x:String x:Key="Text.FileCM.ResolveUsing" xml:space="preserve">应用 '{0}'</x:String>
<x:String x:Key="Text.FileCM.SaveAsPatch" xml:space="preserve">另存为补丁...</x:String>
<x:String x:Key="Text.FileCM.Stage" xml:space="preserve">暂存(add)</x:String>
<x:String x:Key="Text.FileCM.StageMulti" xml:space="preserve">暂存(add){0} 个文件</x:String>

View file

@ -284,6 +284,7 @@
<x:String x:Key="Text.FileCM.DiscardMulti" xml:space="preserve">捨棄已選的 {0} 個檔案變更...</x:String>
<x:String x:Key="Text.FileCM.DiscardSelectedLines" xml:space="preserve">捨棄選取的變更</x:String>
<x:String x:Key="Text.FileCM.OpenWithExternalMerger" xml:space="preserve">使用外部合併工具開啟</x:String>
<x:String x:Key="Text.FileCM.ResolveUsing" xml:space="preserve">使用 '{0}'</x:String>
<x:String x:Key="Text.FileCM.SaveAsPatch" xml:space="preserve">另存為修補檔 (patch)...</x:String>
<x:String x:Key="Text.FileCM.Stage" xml:space="preserve">暫存 (add)</x:String>
<x:String x:Key="Text.FileCM.StageMulti" xml:space="preserve">暫存 (add) 已選的 {0} 個檔案</x:String>

View file

@ -81,6 +81,12 @@ namespace SourceGit.ViewModels
public class RebaseInProgress : InProgressContext
{
public string HeadName
{
get;
private set;
}
public Models.Commit StoppedAt
{
get;
@ -93,6 +99,10 @@ namespace SourceGit.ViewModels
var stoppedSHA = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "stopped-sha")).Trim();
StoppedAt = new Commands.QuerySingleCommit(repo.FullPath, stoppedSHA).Result();
HeadName = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "head-name")).Trim();
if (HeadName.StartsWith("refs/heads/"))
HeadName = HeadName.Substring(11);
}
public override bool Continue()

View file

@ -569,6 +569,22 @@ namespace SourceGit.ViewModels
e.Handled = true;
};
if (_inProgressContext is RebaseInProgress rebase)
{
useTheirs.Header = App.Text("FileCM.ResolveUsing", rebase.HeadName);
useMine.Header = App.Text("FileCM.ResolveUsing", rebase.StoppedAt.SHA.Substring(0, 10));
}
else if (_inProgressContext is CherryPickInProgress cherryPick)
{
useTheirs.Header = App.Text("FileCM.ResolveUsing", cherryPick.Head.SHA.Substring(0, 10));
useMine.Header = App.Text("FileCM.ResolveUsing", _repo.CurrentBranch.Name);
}
else if (_inProgressContext is MergeInProgress merge)
{
useTheirs.Header = App.Text("FileCM.ResolveUsing", merge.SourceName);
useMine.Header = App.Text("FileCM.ResolveUsing", _repo.CurrentBranch.Name);
}
menu.Items.Add(useTheirs);
menu.Items.Add(useMine);
menu.Items.Add(openMerger);
@ -892,6 +908,22 @@ namespace SourceGit.ViewModels
e.Handled = true;
};
if (_inProgressContext is RebaseInProgress rebase)
{
useTheirs.Header = App.Text("FileCM.ResolveUsing", rebase.HeadName);
useMine.Header = App.Text("FileCM.ResolveUsing", rebase.StoppedAt.SHA.Substring(0, 10));
}
else if (_inProgressContext is CherryPickInProgress cherryPick)
{
useTheirs.Header = App.Text("FileCM.ResolveUsing", cherryPick.Head.SHA.Substring(0, 10));
useMine.Header = App.Text("FileCM.ResolveUsing", _repo.CurrentBranch.Name);
}
else if (_inProgressContext is MergeInProgress merge)
{
useTheirs.Header = App.Text("FileCM.ResolveUsing", merge.SourceName);
useMine.Header = App.Text("FileCM.ResolveUsing", _repo.CurrentBranch.Name);
}
menu.Items.Add(useTheirs);
menu.Items.Add(useMine);
return menu;