From eb441852b0d950b2cb3417ca9a75286d6725b722 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 8 Aug 2024 15:18:35 +0800 Subject: [PATCH] enhance: allow edit commit message only with `Amend` (#336) --- src/ViewModels/WorkingCopy.cs | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index a3685875..b4a08fdb 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -1238,25 +1238,33 @@ namespace SourceGit.ViewModels App.RaiseException(_repo.FullPath, "Repository has unfinished job! Please wait!"); return; } - - if (_count == 0) - { - App.RaiseException(_repo.FullPath, "No files added to commit!"); - return; - } - - if (!AutoStageBeforeCommit && _staged.Count == 0) - { - App.RaiseException(_repo.FullPath, "No files added to commit!"); - return; - } - + if (string.IsNullOrWhiteSpace(_commitMessage)) { App.RaiseException(_repo.FullPath, "Commit without message is NOT allowed!"); return; } + if (!_useAmend) + { + if (AutoStageBeforeCommit) + { + if (_count == 0) + { + App.RaiseException(_repo.FullPath, "No files added to commit!"); + return; + } + } + else + { + if (_staged.Count == 0) + { + App.RaiseException(_repo.FullPath, "No files added to commit!"); + return; + } + } + } + IsCommitting = true; _repo.Settings.PushCommitMessage(_commitMessage); _repo.SetWatcherEnabled(false);