From 9c3294c285d18123038ac5dff991ffc39f0c9d87 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 26 Feb 2024 11:29:57 +0800 Subject: [PATCH] optimize<*>: App.RaiseException should be called in UIThread; add default progress description for popups; --- src/Commands/GitFlow.cs | 11 ++++++++--- src/Commands/MergeTool.cs | 19 ++++++++++++++----- src/Commands/SaveChangesAsPatch.cs | 7 +++++-- src/Commands/SaveRevisionFile.cs | 7 +++++-- src/ViewModels/AddRemote.cs | 3 ++- src/ViewModels/AddSubmodule.cs | 2 ++ src/ViewModels/Apply.cs | 2 ++ src/ViewModels/Archive.cs | 8 +++++++- src/ViewModels/Checkout.cs | 3 ++- src/ViewModels/CherryPick.cs | 3 ++- src/ViewModels/Cleanup.cs | 2 +- src/ViewModels/ClearStashes.cs | 2 ++ src/ViewModels/Clone.cs | 2 ++ src/ViewModels/CreateTag.cs | 2 ++ src/ViewModels/DeleteBranch.cs | 2 ++ src/ViewModels/DeleteRemote.cs | 3 ++- src/ViewModels/DeleteSubmodule.cs | 2 ++ src/ViewModels/DeleteTag.cs | 3 ++- src/ViewModels/Discard.cs | 4 ++-- src/ViewModels/DropStash.cs | 2 ++ src/ViewModels/EditRemote.cs | 4 ++-- src/ViewModels/FastForwardWithoutCheckout.cs | 3 ++- src/ViewModels/Init.cs | 3 ++- src/ViewModels/InitGitFlow.cs | 2 ++ src/ViewModels/Merge.cs | 3 ++- src/ViewModels/PruneRemote.cs | 3 ++- src/ViewModels/Push.cs | 6 ++++-- src/ViewModels/PushTag.cs | 3 ++- src/ViewModels/Rebase.cs | 2 ++ src/ViewModels/RenameBranch.cs | 3 ++- src/ViewModels/Reset.cs | 3 ++- src/ViewModels/Revert.cs | 3 ++- src/ViewModels/Reword.cs | 3 ++- src/ViewModels/Squash.cs | 2 ++ src/ViewModels/StashChanges.cs | 2 ++ 35 files changed, 100 insertions(+), 34 deletions(-) diff --git a/src/Commands/GitFlow.cs b/src/Commands/GitFlow.cs index 8aaa45b6..0d277f58 100644 --- a/src/Commands/GitFlow.cs +++ b/src/Commands/GitFlow.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using Avalonia.Threading; +using System.Collections.Generic; namespace SourceGit.Commands { public class GitFlow : Command { @@ -42,7 +43,9 @@ namespace SourceGit.Commands { Args = $"flow hotfix start {name}"; break; default: - App.RaiseException(Context, "Bad branch type!!!"); + Dispatcher.UIThread.Invoke(() => { + App.RaiseException(Context, "Bad branch type!!!"); + }); return false; } @@ -62,7 +65,9 @@ namespace SourceGit.Commands { Args = $"flow hotfix finish {option} {name} -m \"HOTFIX_DONE\""; break; default: - App.RaiseException(Context, "Bad branch type!!!"); + Dispatcher.UIThread.Invoke(() => { + App.RaiseException(Context, "Bad branch type!!!"); + }); return false; } diff --git a/src/Commands/MergeTool.cs b/src/Commands/MergeTool.cs index 4d02f029..d1857636 100644 --- a/src/Commands/MergeTool.cs +++ b/src/Commands/MergeTool.cs @@ -1,15 +1,20 @@ -using System.IO; +using Avalonia.Threading; +using System.IO; namespace SourceGit.Commands { public static class MergeTool { public static bool OpenForMerge(string repo, string tool, string mergeCmd, string file) { if (string.IsNullOrWhiteSpace(tool) || string.IsNullOrWhiteSpace(mergeCmd)) { - App.RaiseException(repo, "Invalid external merge tool settings!"); + Dispatcher.UIThread.Invoke(() => { + App.RaiseException(repo, "Invalid external merge tool settings!"); + }); return false; } if (!File.Exists(tool)) { - App.RaiseException(repo, $"Can NOT found external merge tool in '{tool}'!"); + Dispatcher.UIThread.Invoke(() => { + App.RaiseException(repo, $"Can NOT found external merge tool in '{tool}'!"); + }); return false; } @@ -22,12 +27,16 @@ namespace SourceGit.Commands { public static bool OpenForDiff(string repo, string tool, string diffCmd, Models.DiffOption option) { if (string.IsNullOrWhiteSpace(tool) || string.IsNullOrWhiteSpace(diffCmd)) { - App.RaiseException(repo, "Invalid external merge tool settings!"); + Dispatcher.UIThread.Invoke(() => { + App.RaiseException(repo, "Invalid external merge tool settings!"); + }); return false; } if (!File.Exists(tool)) { - App.RaiseException(repo, $"Can NOT found external merge tool in '{tool}'!"); + Dispatcher.UIThread.Invoke(() => { + App.RaiseException(repo, $"Can NOT found external merge tool in '{tool}'!"); + }); return false; } diff --git a/src/Commands/SaveChangesAsPatch.cs b/src/Commands/SaveChangesAsPatch.cs index 88571632..8a2a7bc6 100644 --- a/src/Commands/SaveChangesAsPatch.cs +++ b/src/Commands/SaveChangesAsPatch.cs @@ -1,4 +1,5 @@ -using System; +using Avalonia.Threading; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -35,7 +36,9 @@ namespace SourceGit.Commands { return rs; } catch (Exception e) { - App.RaiseException(repo, "Save change to patch failed: " + e.Message); + Dispatcher.UIThread.Invoke(() => { + App.RaiseException(repo, "Save change to patch failed: " + e.Message); + }); return false; } } diff --git a/src/Commands/SaveRevisionFile.cs b/src/Commands/SaveRevisionFile.cs index 85944a89..bd38b617 100644 --- a/src/Commands/SaveRevisionFile.cs +++ b/src/Commands/SaveRevisionFile.cs @@ -1,4 +1,5 @@ -using System; +using Avalonia.Threading; +using System; using System.Diagnostics; using System.IO; @@ -51,7 +52,9 @@ namespace SourceGit.Commands { return rs; } catch (Exception e) { - App.RaiseException(repo, "Save file failed: " + e.Message); + Dispatcher.UIThread.Invoke(() => { + App.RaiseException(repo, "Save file failed: " + e.Message); + }); return false; } } diff --git a/src/ViewModels/AddRemote.cs b/src/ViewModels/AddRemote.cs index 8bb2652a..f20422b7 100644 --- a/src/ViewModels/AddRemote.cs +++ b/src/ViewModels/AddRemote.cs @@ -57,8 +57,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Adding remote ..."; + return Task.Run(() => { - SetProgressDescription("Adding remote ..."); var succ = new Commands.Remote(_repo.FullPath).Add(_name, _url); if (succ) { SetProgressDescription("Fetching from added remote ..."); diff --git a/src/ViewModels/AddSubmodule.cs b/src/ViewModels/AddSubmodule.cs index 1e2e1c02..2bfdde3c 100644 --- a/src/ViewModels/AddSubmodule.cs +++ b/src/ViewModels/AddSubmodule.cs @@ -47,6 +47,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Adding submodule..."; + return Task.Run(() => { var succ = new Commands.Submodule(_repo.FullPath).Add(_url, _relativePath, Recursive, SetProgressDescription); CallUIThread(() => _repo.SetWatcherEnabled(true)); diff --git a/src/ViewModels/Apply.cs b/src/ViewModels/Apply.cs index c3685426..0c977e58 100644 --- a/src/ViewModels/Apply.cs +++ b/src/ViewModels/Apply.cs @@ -51,6 +51,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Apply patch..."; + return Task.Run(() => { var succ = new Commands.Apply(_repo.FullPath, _patchFile, _ignoreWhiteSpace, SelectedWhiteSpaceMode.Arg).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); diff --git a/src/ViewModels/Archive.cs b/src/ViewModels/Archive.cs index 3661a978..b9c172f6 100644 --- a/src/ViewModels/Archive.cs +++ b/src/ViewModels/Archive.cs @@ -42,9 +42,15 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Archiving ..."; + return Task.Run(() => { var succ = new Commands.Archive(_repo.FullPath, _revision, _saveFile, SetProgressDescription).Exec(); - CallUIThread(() => _repo.SetWatcherEnabled(true)); + CallUIThread(() => { + _repo.SetWatcherEnabled(true); + if (succ) App.SendNotification(_repo.FullPath, $"Save archive to : {_saveFile}"); + }); + return succ; }); } diff --git a/src/ViewModels/Checkout.cs b/src/ViewModels/Checkout.cs index 33c70d6b..9570b265 100644 --- a/src/ViewModels/Checkout.cs +++ b/src/ViewModels/Checkout.cs @@ -15,8 +15,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = $"Checkout '{Branch}' ..."; + return Task.Run(() => { - SetProgressDescription($"Checkout '{Branch}' ..."); var succ = new Commands.Checkout(_repo.FullPath).Branch(Branch, SetProgressDescription); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/CherryPick.cs b/src/ViewModels/CherryPick.cs index 658c1e0e..2844effb 100644 --- a/src/ViewModels/CherryPick.cs +++ b/src/ViewModels/CherryPick.cs @@ -21,8 +21,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = $"Cherry-Pick commit '{Target.SHA}' ..."; + return Task.Run(() => { - SetProgressDescription($"Cherry-Pick commit '{Target.SHA}' ..."); var succ = new Commands.CherryPick(_repo.FullPath, Target.SHA, !AutoCommit).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/Cleanup.cs b/src/ViewModels/Cleanup.cs index 07561d5e..a90b08f1 100644 --- a/src/ViewModels/Cleanup.cs +++ b/src/ViewModels/Cleanup.cs @@ -10,8 +10,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); ProgressDescription = "Cleanup (GC & prune) ..."; + return Task.Run(() => { - SetProgressDescription("Run GC ..."); new Commands.GC(_repo.FullPath, SetProgressDescription).Exec(); var lfs = new Commands.LFS(_repo.FullPath); diff --git a/src/ViewModels/ClearStashes.cs b/src/ViewModels/ClearStashes.cs index ba10adbf..40a36084 100644 --- a/src/ViewModels/ClearStashes.cs +++ b/src/ViewModels/ClearStashes.cs @@ -9,6 +9,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Clear all stashes..."; + return Task.Run(() => { new Commands.Stash(_repo.FullPath).Clear(); CallUIThread(() => _repo.SetWatcherEnabled(true)); diff --git a/src/ViewModels/Clone.cs b/src/ViewModels/Clone.cs index ba5c4610..afc6cb90 100644 --- a/src/ViewModels/Clone.cs +++ b/src/ViewModels/Clone.cs @@ -59,6 +59,8 @@ namespace SourceGit.ViewModels { } public override Task Sure() { + ProgressDescription = "Clone ..."; + return Task.Run(() => { var cmd = new Commands.Clone(HostPageId, _parentFolder, _remote, _local, _useSSH ? _sshKey : "", _extraArgs, SetProgressDescription); if (!cmd.Exec()) return false; diff --git a/src/ViewModels/CreateTag.cs b/src/ViewModels/CreateTag.cs index ef33d0b3..494fc3fc 100644 --- a/src/ViewModels/CreateTag.cs +++ b/src/ViewModels/CreateTag.cs @@ -50,6 +50,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Create tag..."; + return Task.Run(() => { Commands.Tag.Add(_repo.FullPath, TagName, _basedOn, Message); CallUIThread(() => _repo.SetWatcherEnabled(true)); diff --git a/src/ViewModels/DeleteBranch.cs b/src/ViewModels/DeleteBranch.cs index 0421cf04..924ee12b 100644 --- a/src/ViewModels/DeleteBranch.cs +++ b/src/ViewModels/DeleteBranch.cs @@ -15,6 +15,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Deleting branch..."; + return Task.Run(() => { if (Target.IsLocal) { Commands.Branch.Delete(_repo.FullPath, Target.Name); diff --git a/src/ViewModels/DeleteRemote.cs b/src/ViewModels/DeleteRemote.cs index 2ede9853..513865ba 100644 --- a/src/ViewModels/DeleteRemote.cs +++ b/src/ViewModels/DeleteRemote.cs @@ -15,8 +15,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Deleting remote ..."; + return Task.Run(() => { - SetProgressDescription("Deleting remote ..."); var succ = new Commands.Remote(_repo.FullPath).Delete(Remote.Name); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/DeleteSubmodule.cs b/src/ViewModels/DeleteSubmodule.cs index 2d7f1d5c..41b0fbca 100644 --- a/src/ViewModels/DeleteSubmodule.cs +++ b/src/ViewModels/DeleteSubmodule.cs @@ -16,6 +16,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Deleting submodule ..."; + return Task.Run(() => { var succ = new Commands.Submodule(_repo.FullPath).Delete(Submodule); CallUIThread(() => _repo.SetWatcherEnabled(true)); diff --git a/src/ViewModels/DeleteTag.cs b/src/ViewModels/DeleteTag.cs index 3b33e000..9890a535 100644 --- a/src/ViewModels/DeleteTag.cs +++ b/src/ViewModels/DeleteTag.cs @@ -21,8 +21,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = $"Deleting tag '{Target.Name}' ..."; + return Task.Run(() => { - SetProgressDescription($"Deleting tag '{Target.Name}' ..."); var remotes = ShouldPushToRemote ? _repo.Remotes : null; var succ = Commands.Tag.Delete(_repo.FullPath, Target.Name, remotes); CallUIThread(() => _repo.SetWatcherEnabled(true)); diff --git a/src/ViewModels/Discard.cs b/src/ViewModels/Discard.cs index 4f091448..8e5e9f95 100644 --- a/src/ViewModels/Discard.cs +++ b/src/ViewModels/Discard.cs @@ -30,12 +30,12 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = _changes == null ? "Discard all local changes ..." : $"Discard total {_changes.Count} changes ..."; + return Task.Run(() => { if (_changes == null) { - SetProgressDescription("Discard all local changes ..."); Commands.Discard.All(_repo.FullPath); } else { - SetProgressDescription($"Discard total {_changes.Count} changes ..."); Commands.Discard.Changes(_repo.FullPath, _changes); } diff --git a/src/ViewModels/DropStash.cs b/src/ViewModels/DropStash.cs index 767bdd9f..87926503 100644 --- a/src/ViewModels/DropStash.cs +++ b/src/ViewModels/DropStash.cs @@ -11,6 +11,8 @@ namespace SourceGit.ViewModels { } public override Task Sure() { + ProgressDescription = $"Dropping stash: {Stash.Name}"; + return Task.Run(() => { new Commands.Stash(_repo).Drop(Stash.Name); return true; diff --git a/src/ViewModels/EditRemote.cs b/src/ViewModels/EditRemote.cs index 48082cc2..ae735a80 100644 --- a/src/ViewModels/EditRemote.cs +++ b/src/ViewModels/EditRemote.cs @@ -68,9 +68,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); - return Task.Run(() => { - SetProgressDescription($"Editing remote '{_remote.Name}' ..."); + ProgressDescription = $"Editing remote '{_remote.Name}' ..."; + return Task.Run(() => { if (_remote.Name != _name) { var succ = new Commands.Remote(_repo.FullPath).Rename(_remote.Name, _name); if (succ) _remote.Name = _name; diff --git a/src/ViewModels/FastForwardWithoutCheckout.cs b/src/ViewModels/FastForwardWithoutCheckout.cs index d9eb5462..5d2da837 100644 --- a/src/ViewModels/FastForwardWithoutCheckout.cs +++ b/src/ViewModels/FastForwardWithoutCheckout.cs @@ -21,8 +21,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Fast-Forward ..."; + return Task.Run(() => { - SetProgressDescription("Fast-Forward ..."); new Commands.Fetch(_repo.FullPath, To.Remote, Local.Name, To.Name, SetProgressDescription).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return true; diff --git a/src/ViewModels/Init.cs b/src/ViewModels/Init.cs index f95ed80d..9381b568 100644 --- a/src/ViewModels/Init.cs +++ b/src/ViewModels/Init.cs @@ -14,8 +14,9 @@ namespace SourceGit.ViewModels { } public override Task Sure() { + ProgressDescription = $"Initialize git repository at: '{_targetPath}'"; + return Task.Run(() => { - SetProgressDescription($"Initialize git repository at: '{_targetPath}'"); var succ = new Commands.Init(HostPageId, _targetPath).Exec(); if (!succ) return false; diff --git a/src/ViewModels/InitGitFlow.cs b/src/ViewModels/InitGitFlow.cs index 724310ee..b63db27e 100644 --- a/src/ViewModels/InitGitFlow.cs +++ b/src/ViewModels/InitGitFlow.cs @@ -72,6 +72,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Init git-flow ..."; + return Task.Run(() => { var succ = new Commands.GitFlow(_repo.FullPath).Init(_repo.Branches, _master, _develop, _featurePrefix, _releasePrefix, _hotfixPrefix, _tagPrefix); if (succ) { diff --git a/src/ViewModels/Merge.cs b/src/ViewModels/Merge.cs index b7628739..3f68796a 100644 --- a/src/ViewModels/Merge.cs +++ b/src/ViewModels/Merge.cs @@ -51,8 +51,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = $"Merging '{Source}' into '{Into}' ..."; + return Task.Run(() => { - SetProgressDescription($"Merging '{Source}' into '{Into}' ..."); var succ = new Commands.Merge(_repo.FullPath, Source, SelectedMode.Arg, SetProgressDescription).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/PruneRemote.cs b/src/ViewModels/PruneRemote.cs index 9d93fd18..c256281b 100644 --- a/src/ViewModels/PruneRemote.cs +++ b/src/ViewModels/PruneRemote.cs @@ -15,8 +15,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Run `prune` on remote ..."; + return Task.Run(() => { - SetProgressDescription("Run `prune` on remote ..."); var succ = new Commands.Remote(_repo.FullPath).Prune(Remote.Name); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/Push.cs b/src/ViewModels/Push.cs index 1a71ccc8..73f8c42a 100644 --- a/src/ViewModels/Push.cs +++ b/src/ViewModels/Push.cs @@ -111,9 +111,11 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + + var remoteBranchName = _selectedRemoteBranch.Name.Replace(" (new)", ""); + ProgressDescription = $"Push {_selectedLocalBranch.Name} -> {_selectedRemote.Name}/{remoteBranchName} ..."; + return Task.Run(() => { - var remoteBranchName = _selectedRemoteBranch.Name.Replace(" (new)", ""); - SetProgressDescription($"Push {_selectedLocalBranch.Name} -> {_selectedRemote.Name}/{remoteBranchName} ..."); var succ = new Commands.Push( _repo.FullPath, _selectedLocalBranch.Name, diff --git a/src/ViewModels/PushTag.cs b/src/ViewModels/PushTag.cs index 77b70998..c3a8172e 100644 --- a/src/ViewModels/PushTag.cs +++ b/src/ViewModels/PushTag.cs @@ -26,8 +26,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = $"Pushing tag '{Target.Name}' to remote '{SelectedRemote.Name}' ..."; + return Task.Run(() => { - SetProgressDescription($"Pushing tag '{Target.Name}' to remote '{SelectedRemote.Name}' ..."); var succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/Rebase.cs b/src/ViewModels/Rebase.cs index 6789c9cc..07c579c9 100644 --- a/src/ViewModels/Rebase.cs +++ b/src/ViewModels/Rebase.cs @@ -37,6 +37,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Rebasing ..."; + return Task.Run(() => { var succ = new Commands.Rebase(_repo.FullPath, _revision, AutoStash).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); diff --git a/src/ViewModels/RenameBranch.cs b/src/ViewModels/RenameBranch.cs index 0db0b2e9..b3056853 100644 --- a/src/ViewModels/RenameBranch.cs +++ b/src/ViewModels/RenameBranch.cs @@ -39,8 +39,9 @@ namespace SourceGit.ViewModels { if (_name == Target.Name) return null; _repo.SetWatcherEnabled(false); + ProgressDescription = $"Rename '{Target.Name}'"; + return Task.Run(() => { - SetProgressDescription($"Rename '{Target.Name}'"); var succ = Commands.Branch.Rename(_repo.FullPath, Target.Name, _name); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/Reset.cs b/src/ViewModels/Reset.cs index c415e08a..12ba31ed 100644 --- a/src/ViewModels/Reset.cs +++ b/src/ViewModels/Reset.cs @@ -53,8 +53,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = $"Reset current branch to {To.SHA} ..."; + return Task.Run(() => { - SetProgressDescription($"Reset current branch to {To.SHA} ..."); var succ = new Commands.Reset(_repo.FullPath, To.SHA, SelectedMode.Arg).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/Revert.cs b/src/ViewModels/Revert.cs index 49a379ab..ab3dd927 100644 --- a/src/ViewModels/Revert.cs +++ b/src/ViewModels/Revert.cs @@ -21,8 +21,9 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = $"Revert commit '{Target.SHA}' ..."; + return Task.Run(() => { - SetProgressDescription($"Revert commit '{Target.SHA}' ..."); var succ = new Commands.Revert(_repo.FullPath, Target.SHA, AutoCommit).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/Reword.cs b/src/ViewModels/Reword.cs index f864fa6d..de034162 100644 --- a/src/ViewModels/Reword.cs +++ b/src/ViewModels/Reword.cs @@ -25,8 +25,9 @@ namespace SourceGit.ViewModels { if (_message == Head.FullMessage) return null; _repo.SetWatcherEnabled(false); + ProgressDescription = $"Editing head commit message ..."; + return Task.Run(() => { - SetProgressDescription($"Editing head commit message ..."); var succ = new Commands.Commit(_repo.FullPath, _message, true, true).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/ViewModels/Squash.cs b/src/ViewModels/Squash.cs index 5964b51b..1c4a5547 100644 --- a/src/ViewModels/Squash.cs +++ b/src/ViewModels/Squash.cs @@ -29,6 +29,8 @@ namespace SourceGit.ViewModels { public override Task Sure() { _repo.SetWatcherEnabled(false); + ProgressDescription = "Squashing ..."; + return Task.Run(() => { var succ = new Commands.Reset(_repo.FullPath, Parent.SHA, "--soft").Exec(); if (succ) succ = new Commands.Commit(_repo.FullPath, _message, true).Exec(); diff --git a/src/ViewModels/StashChanges.cs b/src/ViewModels/StashChanges.cs index 7bdecd7c..43d24ab5 100644 --- a/src/ViewModels/StashChanges.cs +++ b/src/ViewModels/StashChanges.cs @@ -42,6 +42,8 @@ namespace SourceGit.ViewModels { if (jobs.Count == 0) return null; _repo.SetWatcherEnabled(false); + ProgressDescription = $"Stash changes ..."; + return Task.Run(() => { new Commands.Stash(_repo.FullPath).Push(jobs, Message); CallUIThread(() => _repo.SetWatcherEnabled(true));