From 47f1d847f19ac0184fa6ed84f6bff306c51b1b91 Mon Sep 17 00:00:00 2001 From: Chris McDonnell Date: Thu, 15 May 2025 18:27:53 +0200 Subject: [PATCH] Rename OnCommitSuccess to ClearPreservedCommitMessage In one case it was actually called *before* making a commit (when switching from the commit message panel to committing in the editor). And clearing the preserved message is the only thing it does, so name it after what it does rather than when it's called. --- pkg/gui/controllers/helpers/commits_helper.go | 3 +-- pkg/gui/controllers/helpers/working_tree_helper.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index 188e9d60a..5404ac5c5 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -157,8 +157,7 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp self.c.Context().Push(self.c.Contexts().CommitMessage, types.OnFocusOpts{}) } -func (self *CommitsHelper) OnCommitSuccess() { - // if we have a preserved message we want to clear it on success +func (self *CommitsHelper) ClearPreservedCommitMessage() { self.c.Contexts().CommitMessage.SetPreservedMessageAndLogError("") } diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go index 4d0d1e9da..69d5fa23f 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -112,7 +112,7 @@ func (self *WorkingTreeHelper) handleCommit(summary string, description string, self.c.LogAction(self.c.Tr.Actions.Commit) return self.gpgHelper.WithGpgHandling(cmdObj, git_commands.CommitGpgSign, self.c.Tr.CommittingStatus, func() error { - self.commitsHelper.OnCommitSuccess() + self.commitsHelper.ClearPreservedCommitMessage() return nil }, nil) } @@ -124,7 +124,7 @@ func (self *WorkingTreeHelper) switchFromCommitMessagePanelToEditor(filepath str // access to the last message that the user typed, and it might be very // different from what was last in the commit panel. So the best we can do // here is to always clear the remembered commit message. - self.commitsHelper.OnCommitSuccess() + self.commitsHelper.ClearPreservedCommitMessage() self.c.LogAction(self.c.Tr.Actions.Commit) return self.c.RunSubprocessAndRefresh(