From 763779b529dc8b5856019d851bd91bb3b37836e1 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 26 May 2021 18:58:34 +0800 Subject: [PATCH] feature: show progress for merge --- src/Commands/Merge.cs | 13 +++++++++++-- src/Views/Popups/Merge.xaml.cs | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Commands/Merge.cs b/src/Commands/Merge.cs index ee827390..a44c72a1 100644 --- a/src/Commands/Merge.cs +++ b/src/Commands/Merge.cs @@ -1,12 +1,21 @@ +using System; + namespace SourceGit.Commands { /// /// 合并分支 /// public class Merge : Command { + private Action handler = null; - public Merge(string repo, string source, string mode) { + public Merge(string repo, string source, string mode, Action onProgress) { Cwd = repo; - Args = $"merge {source} {mode}"; + Args = $"merge --progress {source} {mode}"; + TraitErrorAsOutput = true; + handler = onProgress; + } + + public override void OnReadline(string line) { + handler?.Invoke(line); } } } diff --git a/src/Views/Popups/Merge.xaml.cs b/src/Views/Popups/Merge.xaml.cs index 06406038..dd3f2f98 100644 --- a/src/Views/Popups/Merge.xaml.cs +++ b/src/Views/Popups/Merge.xaml.cs @@ -26,7 +26,7 @@ namespace SourceGit.Views.Popups { var mode = (cmbMode.SelectedItem as Models.MergeOption).Arg; return Task.Run(() => { Models.Watcher.SetEnabled(repo, false); - new Commands.Merge(repo, source, mode).Exec(); + new Commands.Merge(repo, source, mode, UpdateProgress).Exec(); Models.Watcher.SetEnabled(repo, true); return true; });