mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: show source branch/tag/commit in banner while merging request in progress
This commit is contained in:
parent
e1df5c52f1
commit
ef40e4b738
7 changed files with 66 additions and 7 deletions
|
@ -2,6 +2,15 @@
|
|||
{
|
||||
public static class Branch
|
||||
{
|
||||
public static string ShowCurrent(string repo)
|
||||
{
|
||||
var cmd = new Command();
|
||||
cmd.WorkingDirectory = repo;
|
||||
cmd.Context = repo;
|
||||
cmd.Args = $"branch --show-current";
|
||||
return cmd.ReadToEnd().StdOut.Trim();
|
||||
}
|
||||
|
||||
public static bool Create(string repo, string name, string basedOn)
|
||||
{
|
||||
var cmd = new Command();
|
||||
|
|
|
@ -394,6 +394,7 @@
|
|||
<x:String x:Key="Text.InProgress.CherryPick" xml:space="preserve">Cherry-Pick in progress.</x:String>
|
||||
<x:String x:Key="Text.InProgress.CherryPick.Head" xml:space="preserve">Processing commit</x:String>
|
||||
<x:String x:Key="Text.InProgress.Merge" xml:space="preserve">Merge request in progress.</x:String>
|
||||
<x:String x:Key="Text.InProgress.Merge.Operating" xml:space="preserve">Operating</x:String>
|
||||
<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>
|
||||
|
|
|
@ -397,6 +397,7 @@
|
|||
<x:String x:Key="Text.InProgress.CherryPick" xml:space="preserve">挑选(Cherry-Pick)操作进行中。</x:String>
|
||||
<x:String x:Key="Text.InProgress.CherryPick.Head" xml:space="preserve">正在处理提交</x:String>
|
||||
<x:String x:Key="Text.InProgress.Merge" xml:space="preserve">合并操作进行中。</x:String>
|
||||
<x:String x:Key="Text.InProgress.Merge.Operating" xml:space="preserve">正在处理</x:String>
|
||||
<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>
|
||||
|
|
|
@ -397,6 +397,7 @@
|
|||
<x:String x:Key="Text.InProgress.CherryPick" xml:space="preserve">揀選 (cherry-pick) 操作進行中。</x:String>
|
||||
<x:String x:Key="Text.InProgress.CherryPick.Head" xml:space="preserve">正在處理提交</x:String>
|
||||
<x:String x:Key="Text.InProgress.Merge" xml:space="preserve">合併操作進行中。</x:String>
|
||||
<x:String x:Key="Text.InProgress.Merge.Operating" xml:space="preserve">正在處理</x:String>
|
||||
<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>
|
||||
|
|
|
@ -129,11 +129,52 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public class RevertInProgress : InProgressContext
|
||||
{
|
||||
public RevertInProgress(string repo) : base(repo, "revert", false) { }
|
||||
public RevertInProgress(Repository repo) : base(repo.FullPath, "revert", false) { }
|
||||
}
|
||||
|
||||
public class MergeInProgress : InProgressContext
|
||||
{
|
||||
public MergeInProgress(string repo) : base(repo, "merge", false) { }
|
||||
public string Current
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string SourceName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Models.Commit Source
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public MergeInProgress(Repository repo) : base(repo.FullPath, "merge", false)
|
||||
{
|
||||
Current = Commands.Branch.ShowCurrent(repo.FullPath);
|
||||
|
||||
var sourceSHA = File.ReadAllText(Path.Combine(repo.GitDir, "MERGE_HEAD")).Trim();
|
||||
Source = new Commands.QuerySingleCommit(repo.FullPath, sourceSHA).Result();
|
||||
if (Source == null)
|
||||
return;
|
||||
|
||||
var branchDecorator = Source.Decorators.Find(x => x.Type == Models.DecoratorType.LocalBranchHead || x.Type == Models.DecoratorType.RemoteBranchHead);
|
||||
if (branchDecorator != null)
|
||||
{
|
||||
SourceName = branchDecorator.Name;
|
||||
return;
|
||||
}
|
||||
|
||||
var tagDecorator = Source.Decorators.Find(x => x.Type == Models.DecoratorType.Tag);
|
||||
if (tagDecorator != null)
|
||||
{
|
||||
SourceName = tagDecorator.Name;
|
||||
}
|
||||
|
||||
SourceName = Source.SHA.Substring(0, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,9 +241,9 @@ namespace SourceGit.ViewModels
|
|||
else if (File.Exists(Path.Combine(_repo.GitDir, "REBASE_HEAD")) && Directory.Exists(Path.Combine(_repo.GitDir, "rebase-merge")))
|
||||
inProgress = new RebaseInProgress(_repo);
|
||||
else if (File.Exists(Path.Combine(_repo.GitDir, "REVERT_HEAD")))
|
||||
inProgress = new RevertInProgress(_repo.FullPath);
|
||||
inProgress = new RevertInProgress(_repo);
|
||||
else if (File.Exists(Path.Combine(_repo.GitDir, "MERGE_HEAD")))
|
||||
inProgress = new MergeInProgress(_repo.FullPath);
|
||||
inProgress = new MergeInProgress(_repo);
|
||||
|
||||
HasUnsolvedConflicts = _cached.Find(x => x.IsConflit) != null;
|
||||
InProgressContext = inProgress;
|
||||
|
@ -314,9 +314,9 @@ namespace SourceGit.ViewModels
|
|||
else if (File.Exists(Path.Combine(_repo.GitDir, "REBASE_HEAD")) && Directory.Exists(Path.Combine(_repo.GitDir, "rebase-merge")))
|
||||
inProgress = new RebaseInProgress(_repo);
|
||||
else if (File.Exists(Path.Combine(_repo.GitDir, "REVERT_HEAD")))
|
||||
inProgress = new RevertInProgress(_repo.FullPath);
|
||||
inProgress = new RevertInProgress(_repo);
|
||||
else if (File.Exists(Path.Combine(_repo.GitDir, "MERGE_HEAD")))
|
||||
inProgress = new MergeInProgress(_repo.FullPath);
|
||||
inProgress = new MergeInProgress(_repo);
|
||||
|
||||
InProgressContext = inProgress;
|
||||
|
||||
|
|
|
@ -583,7 +583,13 @@
|
|||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="vm:MergeInProgress">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontWeight="Bold" Foreground="{DynamicResource Brush.ConflictForeground}" Text="{DynamicResource Text.InProgress.Merge}"/>
|
||||
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="{DynamicResource Brush.ConflictForeground}" Text="{DynamicResource Text.InProgress.Merge.Operating}"/>
|
||||
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="{DynamicResource Brush.Accent}" Text="{Binding SourceName}" ToolTip.Tip="{Binding Source}"/>
|
||||
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="{DynamicResource Brush.ConflictForeground}" Text="→"/>
|
||||
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="{DynamicResource Brush.Accent}" Text="{Binding Current}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
|
Loading…
Reference in a new issue