diff --git a/src/Commands/Branch.cs b/src/Commands/Branch.cs index 4ec8da82..391aeeb2 100644 --- a/src/Commands/Branch.cs +++ b/src/Commands/Branch.cs @@ -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(); diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 3abf59c5..de8df8cb 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -394,6 +394,7 @@ Cherry-Pick in progress. Processing commit Merge request in progress. + Operating Rebase in progress. Stopped at Revert in progress. diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index a257d62b..1ee30437 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -397,6 +397,7 @@ 挑选(Cherry-Pick)操作进行中。 正在处理提交 合并操作进行中。 + 正在处理 变基(Rebase)操作进行中。 当前停止于 回滚提交操作进行中。 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 3056de6d..b604755b 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -397,6 +397,7 @@ 揀選 (cherry-pick) 操作進行中。 正在處理提交 合併操作進行中。 + 正在處理 重定基底 (rebase) 操作進行中。 当前停止于 復原提交操作進行中。 diff --git a/src/ViewModels/InProgressContexts.cs b/src/ViewModels/InProgressContexts.cs index 06417e9e..e398bd12 100644 --- a/src/ViewModels/InProgressContexts.cs +++ b/src/ViewModels/InProgressContexts.cs @@ -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); + } } } diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index f708306c..c2e5d4de 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -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; diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 186bbb7d..7837feac 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -583,7 +583,13 @@ - + + + + + + +