feature<Merge>: show progress for merge

This commit is contained in:
leo 2021-05-26 18:58:34 +08:00
parent 67f5eed9a0
commit 763779b529
2 changed files with 12 additions and 3 deletions

View file

@ -1,12 +1,21 @@
using System;
namespace SourceGit.Commands { namespace SourceGit.Commands {
/// <summary> /// <summary>
/// 合并分支 /// 合并分支
/// </summary> /// </summary>
public class Merge : Command { public class Merge : Command {
private Action<string> handler = null;
public Merge(string repo, string source, string mode) { public Merge(string repo, string source, string mode, Action<string> onProgress) {
Cwd = repo; Cwd = repo;
Args = $"merge {source} {mode}"; Args = $"merge --progress {source} {mode}";
TraitErrorAsOutput = true;
handler = onProgress;
}
public override void OnReadline(string line) {
handler?.Invoke(line);
} }
} }
} }

View file

@ -26,7 +26,7 @@ namespace SourceGit.Views.Popups {
var mode = (cmbMode.SelectedItem as Models.MergeOption).Arg; var mode = (cmbMode.SelectedItem as Models.MergeOption).Arg;
return Task.Run(() => { return Task.Run(() => {
Models.Watcher.SetEnabled(repo, false); 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); Models.Watcher.SetEnabled(repo, true);
return true; return true;
}); });