Repository: jesseduffield/lazygit (Go)

Issue:
Lazygit hangs when creating a new tag with `tag.gpgSign = true` and empty description
## Describe the bug
When `tag.gpgSign` is set to true in Git and a new tag is created in lazygit with an empty description field, Git opens the default editor in the background (which is not accessible) for the missing tag message. Lazygit then waits for it to exit, which never happens. This leaves Lazygit in a state where it is still somewhat usable but very sluggish, for example, keyboard inputs art missing. You have to kill the editor manually.

## To Reproduce
Steps to reproduce the behavior:

- Set tag.gpgSign to true in your git configuration `git config tag.gpgSign true`.
- Open lazygit.
- Create a new tag and leave the description field empty.
- Observe that lazygit hangs ('creating tag' in status bar), waiting for the hidden editor to close.

## Expected behavior
Lazygit should handle the tag creation gracefully, either by enforcing a tag message or by handling the case where the description field is empty without hanging.

Version info:
lazygit: *commit=5e388e21c8ca6aa883dbcbe45c47f6fdd5116815, build date=2023-08-07T14:05:48Z, build source=binaryRelease, version=0.40.2, os=windows, arch=amd64, git version=2.42.0.windows.1*
git: *git version 2.42.0.windows.1*

## Additional context
This issue appears to be specific to the combination of using tag.gpgSign and leaving the tag description field empty in lazygit. 
I assume the default behavior is to create a lightweight tag when the description field is empty. I think Lazygit should consider the `tag.gpgSign` setting and give a hint when the description field is empty and `tag.gpgSign` is set to true.

## Debug log
```
Aug 23 11:17:25 |INFO| postRefreshUpdate for localBranches took 37.3841ms
Aug 23 11:17:25 |DEBU| using cache for key rebase.updateRefs
Aug 23 11:17:25 |INFO| git merge-base HEAD HEAD@{u} (98.1522ms)
Aug 23 11:17:25 |INFO| git merge-base HEAD refs/remotes/origin/main (109.8915ms)
Aug 23 11:17:25 |INFO| git log HEAD --topo-order --oneline --pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%s --abbrev=40 -300 --no-show-signature -- (118.1127ms)
Aug 23 11:17:25 |DEBU| RunCommand command="git rev-parse --abbrev-ref --verify HEAD"
Aug 23 11:17:25 |INFO| git rev-parse --abbrev-ref --verify HEAD (93.1223ms)
Aug 23 11:17:25 |DEBU| using cache for key rebase.updateRefs
Aug 23 11:17:25 |INFO| postRefreshUpdate for commits took 1.0923ms
Aug 23 11:17:26 |DEBU| RunCommand command="git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium refs/tags/v1.2.10 --"
Aug 23 11:17:34 |INFO| refreshing the following scopes in sync mode: files
Aug 23 11:17:34 |INFO| refreshed merge conflicts in 0s
Aug 23 11:17:34 |DEBU| using cache for key status.showUntrackedFiles
Aug 23 11:17:34 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Aug 23 11:17:34 |INFO| git status --untracked-files=all --porcelain -z (99.7917ms)
Aug 23 11:17:34 |INFO| refreshed files in 124.4685ms
Aug 23 11:17:34 |INFO| Refresh took 124.4685ms
Aug 23 11:17:34 |INFO| postRefreshUpdate for submodules took 0s
Aug 23 11:17:34 |INFO| postRefreshUpdate for files took 0s
Aug 23 11:17:43 |DEBU| RunCommand command="git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium refs/tags/v1.2.10 --"
Aug 23 11:17:43 |DEBU| RunCommand command="git show-ref --tags --quiet --verify -- refs/tags/v1.2.11"
Aug 23 11:17:43 |ERRO| <no msg> command="git show-ref --tags --quiet --verify -- refs/tags/v1.2.11"
Aug 23 11:17:43 |INFO| git show-ref --tags --quiet --verify -- refs/tags/v1.2.11 (97.0819ms)
Aug 23 11:17:43 |DEBU| RunCommand command="git tag -- v1.2.11"
Aug 23 11:17:44 |INFO| refreshing the following scopes in sync mode: files
Aug 23 11:17:44 |DEBU| using cache for key status.showUntrackedFiles
Aug 23 11:17:44 |INFO| refreshed merge conflicts in 0s
Aug 23 11:17:44 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Aug 23 11:17:44 |INFO| git status --untracked-files=all --porcelain -z (86.0057ms)
Aug 23 11:17:44 |INFO| refreshed files in 107.8382ms
Aug 23 11:17:44 |INFO| Refresh took 108.857ms
Aug 23 11:17:44 |INFO| postRefreshUpdate for submodules took 0s
Aug 23 11:17:44 |INFO| postRefreshUpdate for files took 0s
Aug 23 11:17:54 |INFO| refreshing the following scopes in sync mode: files
Aug 23 11:17:54 |DEBU| using cache for key status.showUntrackedFiles
Aug 23 11:17:54 |INFO| refreshed merge conflicts in 0s
Aug 23 11:17:54 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Aug 23 11:17:54 |INFO| git status --untracked-files=all --porcelain -z (83.144ms)
Aug 23 11:17:54 |INFO| refreshed files in 105.862ms
Aug 23 11:17:54 |INFO| Refresh took 105.862ms
Aug 23 11:17:54 |INFO| postRefreshUpdate for submodules took 0s
Aug 23 11:17:54 |INFO| postRefreshUpdate for files took 0s
Aug 23 11:18:04 |INFO| refreshing the following scopes in sync mode: files
Aug 23 11:18:04 |INFO| refreshed merge conflicts in 0s
Aug 23 11:18:04 |DEBU| using cache for key status.showUntrackedFiles
Aug 23 11:18:04 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
Aug 23 11:18:04 |INFO| git status --untracked-files=all --porcelain -z (111.6585ms)
Aug 23 11:18:04 |INFO| refreshed files in 138.4393ms
Aug 23 11:18:04 |INFO| Refresh took 139.0411ms
Aug 23 11:18:04 |INFO| postRefreshUpdate for submodules took 0s
Aug 23 11:18:04 |INFO| postRefreshUpdate for files took 0s
Aug 23 11:18:06 |INFO| postRefreshUpdate for stash took 0s
Aug 23 11:18:06 |INFO| postRefreshUpdate for localBranches took 512.6µs
Aug 23 11:18:06 |INFO| postRefreshUpdate for worktrees took 0s
Aug 23 11:18:06 |INFO| git merge-base HEAD refs/remotes/origin/main (271.6646ms)
Aug 23 11:18:06 |INFO| git -c log.showSignature=false log -g --abbrev=40 --format=%h%x00%ct%x00%gs%x00%p (275.5594ms)
Aug 23 11:18:06 |INFO| postRefreshUpdate for reflogCommits took 2.1835ms
Aug 23 11:18:06 |INFO| git log HEAD --topo-order --oneline --pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%s --abbrev=40 -300 --no-show-signature -- (278.8783ms)
Aug 23 11:18:06 |INFO| git status --untracked-files=all --porcelain -z (300.8983ms)
Aug 23 11:18:06 |INFO| postRefreshUpdate for submodules took 0s
Aug 23 11:18:06 |INFO| postRefreshUpdate for files took 54.7µs
Aug 23 11:18:06 |INFO| postRefreshUpdate for submodules took 0s
Aug 23 11:18:06 |INFO| postRefreshUpdate for files took 54.7µs
Aug 23 11:18:07 |DEBU| RunCommand command="git for-each-ref --sort=-committerdate --format=%(HEAD)%00%(refname:short)%00%(upstream:short)%00%(upstream:track)%00%(subject)%00%(objectname) refs/heads"
Aug 23 11:18:07 |DEBU| RunCommand command="git rev-parse --abbrev-ref --verify HEAD"
Aug 23 11:18:07 |INFO| git for-each-ref --sort=-committerdate --format=%(HEAD)%00%(refname:short)%00%(upstream:short)%00%(upstream:track)%00%(subject)%00%(objectname) refs/heads (98.1454ms)
Aug 23 11:18:07 |INFO| postRefreshUpdate for localBranches took 511.2µs
Aug 23 11:18:07 |DEBU| using cache for key rebase.updateRefs
Aug 23 11:18:07 |INFO| git rev-parse --abbrev-ref --verify HEAD (96.7818ms)
Aug 23 11:18:07 |DEBU| using cache for key rebase.updateRefs
Aug 23 11:18:07 |INFO| postRefreshUpdate for commits took 1.1807ms
Aug 23 11:18:11 |DEBU| RunCommand command="git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium refs/tags/v1.2.10 --"
Aug 23 11:18:14 |INFO| refreshing the following scopes in sync mode: files
Aug 23 11:18:14 |INFO| refreshed merge conflicts in 0s
Aug 23 11:18:14 |DEBU| using cache for key status.showUntrackedFiles
Aug 23 11:18:14 |DEBU| RunCommand command="git status --untracked-files=all --porcelain -z"
```


Discussion:
This should at the very least show an error message of why it isn't completing.
This bug report saved my sanity, thank you :)
0.43.1 was affected, 0.48.0 still is.



Patch:
diff --git a/pkg/commands/git_commands/config.go b/pkg/commands/git_commands/config.go
index 5ea8f91d7fd..19849b84bd3 100644
--- a/pkg/commands/git_commands/config.go
+++ b/pkg/commands/git_commands/config.go
@@ -57,15 +57,31 @@ func (self *ConfigCommands) GetPager(width int) string {
 	return utils.ResolvePlaceholderString(pagerTemplate, templateValues)
 }
 
-// UsingGpg tells us whether the user has gpg enabled so that we can know
-// whether we need to run a subprocess to allow them to enter their password
-func (self *ConfigCommands) UsingGpg() bool {
+type GpgConfigKey string
+
+const (
+	CommitGpgSign GpgConfigKey = "commit.gpgSign"
+	TagGpgSign    GpgConfigKey = "tag.gpgSign"
+)
+
+// NeedsGpgSubprocess tells us whether the user has gpg enabled for the specified action type
+// and needs a subprocess because they have a process where they manually
+// enter their password every time a GPG action is taken
+func (self *ConfigCommands) NeedsGpgSubprocess(key GpgConfigKey) bool {
 	overrideGpg := self.UserConfig().Git.OverrideGpg
 	if overrideGpg {
 		return false
 	}
 
-	return self.gitConfig.GetBool("commit.gpgsign")
+	return self.gitConfig.GetBool(string(key))
+}
+
+func (self *ConfigCommands) NeedsGpgSubprocessForCommit() bool {
+	return self.NeedsGpgSubprocess(CommitGpgSign)
+}
+
+func (self *ConfigCommands) GetGpgTagSign() bool {
+	return self.gitConfig.GetBool(string(TagGpgSign))
 }
 
 func (self *ConfigCommands) GetCoreEditor() string {
diff --git a/pkg/commands/git_commands/patch.go b/pkg/commands/git_commands/patch.go
index 830ee2cb6d5..36e094337c4 100644
--- a/pkg/commands/git_commands/patch.go
+++ b/pkg/commands/git_commands/patch.go
@@ -150,7 +150,7 @@ func (self *PatchCommands) MovePatchToSelectedCommit(commits []*models.Commit, s
 	// we can make this GPG thing possible it just means we need to do this in two parts:
 	// one where we handle the possibility of a credential request, and the other
 	// where we continue the rebase
-	if self.config.UsingGpg() {
+	if self.config.NeedsGpgSubprocessForCommit() {
 		return errors.New(self.Tr.DisabledForGPG)
 	}
 
diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go
index 7572577505b..155455a34c0 100644
--- a/pkg/commands/git_commands/rebase.go
+++ b/pkg/commands/git_commands/rebase.go
@@ -35,7 +35,7 @@ func NewRebaseCommands(
 }
 
 func (self *RebaseCommands) RewordCommit(commits []*models.Commit, index int, summary string, description string) error {
-	if self.config.UsingGpg() {
+	if self.config.NeedsGpgSubprocessForCommit() {
 		return errors.New(self.Tr.DisabledForGPG)
 	}
 
@@ -413,7 +413,7 @@ func (self *RebaseCommands) BeginInteractiveRebaseForCommitRange(
 	// we can make this GPG thing possible it just means we need to do this in two parts:
 	// one where we handle the possibility of a credential request, and the other
 	// where we continue the rebase
-	if self.config.UsingGpg() {
+	if self.config.NeedsGpgSubprocessForCommit() {
 		return errors.New(self.Tr.DisabledForGPG)
 	}
 
diff --git a/pkg/commands/git_commands/tag.go b/pkg/commands/git_commands/tag.go
index d2b01ba7eab..9b9103416ff 100644
--- a/pkg/commands/git_commands/tag.go
+++ b/pkg/commands/git_commands/tag.go
@@ -1,6 +1,9 @@
 package git_commands
 
-import "github.com/jesseduffield/gocui"
+import (
+	"github.com/jesseduffield/gocui"
+	"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
+)
 
 type TagCommands struct {
 	*GitCommon
@@ -12,24 +15,24 @@ func NewTagCommands(gitCommon *GitCommon) *TagCommands {
 	}
 }
 
-func (self *TagCommands) CreateLightweight(tagName string, ref string, force bool) error {
+func (self *TagCommands) CreateLightweightObj(tagName string, ref string, force bool) oscommands.ICmdObj {
 	cmdArgs := NewGitCmd("tag").
 		ArgIf(force, "--force").
 		Arg("--", tagName).
 		ArgIf(len(ref) > 0, ref).
 		ToArgv()
 
-	return self.cmd.New(cmdArgs).Run()
+	return self.cmd.New(cmdArgs)
 }
 
-func (self *TagCommands) CreateAnnotated(tagName, ref, msg string, force bool) error {
+func (self *TagCommands) CreateAnnotatedObj(tagName, ref, msg string, force bool) oscommands.ICmdObj {
 	cmdArgs := NewGitCmd("tag").Arg(tagName).
 		ArgIf(force, "--force").
 		ArgIf(len(ref) > 0, ref).
 		Arg("-m", msg).
 		ToArgv()
 
-	return self.cmd.New(cmdArgs).Run()
+	return self.cmd.New(cmdArgs)
 }
 
 func (self *TagCommands) HasTag(tagName string) bool {
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go
index d8ce6766af6..a808d368f51 100644
--- a/pkg/gui/controllers.go
+++ b/pkg/gui/controllers.go
@@ -106,7 +106,7 @@ func (gui *Gui) resetHelpersAndControllers() {
 		Suggestions:     suggestionsHelper,
 		Files:           helpers.NewFilesHelper(helperCommon),
 		WorkingTree:     helpers.NewWorkingTreeHelper(helperCommon, refsHelper, commitsHelper, gpgHelper),
-		Tags:            helpers.NewTagsHelper(helperCommon, commitsHelper),
+		Tags:            helpers.NewTagsHelper(helperCommon, commitsHelper, gpgHelper),
 		BranchesHelper:  helpers.NewBranchesHelper(helperCommon, worktreeHelper),
 		GPG:             helpers.NewGpgHelper(helperCommon),
 		MergeAndRebase:  rebaseHelper,
diff --git a/pkg/gui/controllers/helpers/amend_helper.go b/pkg/gui/controllers/helpers/amend_helper.go
index c3e8a81181b..03c6bb48564 100644
--- a/pkg/gui/controllers/helpers/amend_helper.go
+++ b/pkg/gui/controllers/helpers/amend_helper.go
@@ -1,5 +1,7 @@
 package helpers
 
+import "github.com/jesseduffield/lazygit/pkg/commands/git_commands"
+
 type AmendHelper struct {
 	c   *HelperCommon
 	gpg *GpgHelper
@@ -18,5 +20,5 @@ func NewAmendHelper(
 func (self *AmendHelper) AmendHead() error {
 	cmdObj := self.c.Git().Commit.AmendHeadCmdObj()
 	self.c.LogAction(self.c.Tr.Actions.AmendCommit)
-	return self.gpg.WithGpgHandling(cmdObj, self.c.Tr.AmendingStatus, nil)
+	return self.gpg.WithGpgHandling(cmdObj, git_commands.CommitGpgSign, self.c.Tr.AmendingStatus, nil, nil)
 }
diff --git a/pkg/gui/controllers/helpers/gpg_helper.go b/pkg/gui/controllers/helpers/gpg_helper.go
index 6974e1c5cea..da87d1e6a68 100644
--- a/pkg/gui/controllers/helpers/gpg_helper.go
+++ b/pkg/gui/controllers/helpers/gpg_helper.go
@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/jesseduffield/gocui"
+	"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
 	"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
 	"github.com/jesseduffield/lazygit/pkg/gui/types"
 )
@@ -22,8 +23,8 @@ func NewGpgHelper(c *HelperCommon) *GpgHelper {
 // WithWaitingStatus we get stuck there and can't return to lazygit. We could
 // fix this bug, or just stop running subprocesses from within there, given that
 // we don't need to see a loading status if we're in a subprocess.
-func (self *GpgHelper) WithGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error) error {
-	useSubprocess := self.c.Git().Config.UsingGpg()
+func (self *GpgHelper) WithGpgHandling(cmdObj oscommands.ICmdObj, configKey git_commands.GpgConfigKey, waitingStatus string, onSuccess func() error, refreshScope []types.RefreshableView) error {
+	useSubprocess := self.c.Git().Config.NeedsGpgSubprocess(configKey)
 	if useSubprocess {
 		success, err := self.c.RunSubprocess(cmdObj)
 		if success && onSuccess != nil {
@@ -31,20 +32,20 @@ func (self *GpgHelper) WithGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus
 				return err
 			}
 		}
-		if err := self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}); err != nil {
+		if err := self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: refreshScope}); err != nil {
 			return err
 		}
 
 		return err
 	} else {
-		return self.runAndStream(cmdObj, waitingStatus, onSuccess)
+		return self.runAndStream(cmdObj, waitingStatus, onSuccess, refreshScope)
 	}
 }
 
-func (self *GpgHelper) runAndStream(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error) error {
+func (self *GpgHelper) runAndStream(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error, refreshScope []types.RefreshableView) error {
 	return self.c.WithWaitingStatus(waitingStatus, func(gocui.Task) error {
 		if err := cmdObj.StreamOutput().Run(); err != nil {
-			_ = self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
+			_ = self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: refreshScope})
 			return fmt.Errorf(
 				self.c.Tr.GitCommandFailed, self.c.UserConfig().Keybinding.Universal.ExtrasMenu,
 			)
@@ -56,6 +57,6 @@ func (self *GpgHelper) runAndStream(cmdObj oscommands.ICmdObj, waitingStatus str
 			}
 		}
 
-		return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
+		return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: refreshScope})
 	})
 }
diff --git a/pkg/gui/controllers/helpers/tags_helper.go b/pkg/gui/controllers/helpers/tags_helper.go
index aa6ff7740ae..b247ad838f6 100644
--- a/pkg/gui/controllers/helpers/tags_helper.go
+++ b/pkg/gui/controllers/helpers/tags_helper.go
@@ -1,7 +1,8 @@
 package helpers
 
 import (
-	"github.com/jesseduffield/gocui"
+	"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
+	"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
 	"github.com/jesseduffield/lazygit/pkg/gui/context"
 	"github.com/jesseduffield/lazygit/pkg/gui/types"
 	"github.com/jesseduffield/lazygit/pkg/utils"
@@ -10,36 +11,32 @@ import (
 type TagsHelper struct {
 	c             *HelperCommon
 	commitsHelper *CommitsHelper
+	gpg           *GpgHelper
 }
 
-func NewTagsHelper(c *HelperCommon, commitsHelper *CommitsHelper) *TagsHelper {
+func NewTagsHelper(c *HelperCommon, commitsHelper *CommitsHelper, gpg *GpgHelper) *TagsHelper {
 	return &TagsHelper{
 		c:             c,
 		commitsHelper: commitsHelper,
+		gpg:           gpg,
 	}
 }
 
 func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error {
 	doCreateTag := func(tagName string, description string, force bool) error {
-		return self.c.WithWaitingStatus(self.c.Tr.CreatingTag, func(gocui.Task) error {
-			if description != "" {
-				self.c.LogAction(self.c.Tr.Actions.CreateAnnotatedTag)
-				if err := self.c.Git().Tag.CreateAnnotated(tagName, ref, description, force); err != nil {
-					return err
-				}
-			} else {
-				self.c.LogAction(self.c.Tr.Actions.CreateLightweightTag)
-				if err := self.c.Git().Tag.CreateLightweight(tagName, ref, force); err != nil {
-					return err
-				}
-			}
+		var command oscommands.ICmdObj
+		if description != "" || self.c.Git().Config.GetGpgTagSign() {
+			self.c.LogAction(self.c.Tr.Actions.CreateAnnotatedTag)
+			command = self.c.Git().Tag.CreateAnnotatedObj(tagName, ref, description, force)
+		} else {
+			self.c.LogAction(self.c.Tr.Actions.CreateLightweightTag)
+			command = self.c.Git().Tag.CreateLightweightObj(tagName, ref, force)
+		}
 
+		return self.gpg.WithGpgHandling(command, git_commands.TagGpgSign, self.c.Tr.CreatingTag, func() error {
 			self.commitsHelper.OnCommitSuccess()
-
-			return self.c.Refresh(types.RefreshOptions{
-				Mode: types.ASYNC, Scope: []types.RefreshableView{types.COMMITS, types.TAGS},
-			})
-		})
+			return nil
+		}, []types.RefreshableView{types.COMMITS, types.TAGS})
 	}
 
 	onConfirm := func(tagName string, description string) error {
diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go
index acec444ad52..e85e6702e0f 100644
--- a/pkg/gui/controllers/helpers/working_tree_helper.go
+++ b/pkg/gui/controllers/helpers/working_tree_helper.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"regexp"
 
+	"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
 	"github.com/jesseduffield/lazygit/pkg/commands/models"
 	"github.com/jesseduffield/lazygit/pkg/config"
 	"github.com/jesseduffield/lazygit/pkg/gui/context"
@@ -111,10 +112,11 @@ func (self *WorkingTreeHelper) HandleCommitPressWithMessage(initialMessage strin
 func (self *WorkingTreeHelper) handleCommit(summary string, description string, forceSkipHooks bool) error {
 	cmdObj := self.c.Git().Commit.CommitCmdObj(summary, description, forceSkipHooks)
 	self.c.LogAction(self.c.Tr.Actions.Commit)
-	return self.gpgHelper.WithGpgHandling(cmdObj, self.c.Tr.CommittingStatus, func() error {
-		self.commitsHelper.OnCommitSuccess()
-		return nil
-	})
+	return self.gpgHelper.WithGpgHandling(cmdObj, git_commands.CommitGpgSign, self.c.Tr.CommittingStatus,
+		func() error {
+			self.commitsHelper.OnCommitSuccess()
+			return nil
+		}, nil)
 }
 
 func (self *WorkingTreeHelper) switchFromCommitMessagePanelToEditor(filepath string, forceSkipHooks bool) error {
diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go
index 53885c8f5ff..c459f426137 100644
--- a/pkg/gui/controllers/local_commits_controller.go
+++ b/pkg/gui/controllers/local_commits_controller.go
@@ -6,6 +6,7 @@ import (
 
 	"github.com/go-errors/errors"
 	"github.com/jesseduffield/gocui"
+	"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
 	"github.com/jesseduffield/lazygit/pkg/commands/models"
 	"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
 	"github.com/jesseduffield/lazygit/pkg/gui/context"
@@ -412,7 +413,8 @@ func (self *LocalCommitsController) handleReword(summary string, description str
 	if models.IsHeadCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx()) {
 		// we've selected the top commit so no rebase is required
 		return self.c.Helpers().GPG.WithGpgHandling(self.c.Git().Commit.RewordLastCommit(summary, description),
-			self.c.Tr.RewordingStatus, nil)
+			git_commands.CommitGpgSign,
+			self.c.Tr.RewordingStatus, nil, nil)
 	}
 
 	return self.c.WithWaitingStatus(self.c.Tr.RewordingStatus, func(gocui.Task) error {


Test patch:
diff --git a/pkg/commands/git_commands/rebase_test.go b/pkg/commands/git_commands/rebase_test.go
index 21ebdf365dc..d79bc0b6acf 100644
--- a/pkg/commands/git_commands/rebase_test.go
+++ b/pkg/commands/git_commands/rebase_test.go
@@ -128,7 +128,7 @@ func TestRebaseDiscardOldFileChanges(t *testing.T) {
 		},
 		{
 			testName:               "returns error when using gpg",
-			gitConfigMockResponses: map[string]string{"commit.gpgsign": "true"},
+			gitConfigMockResponses: map[string]string{"commit.gpgSign": "true"},
 			commits:                []*models.Commit{{Name: "commit", Hash: "123456"}},
 			commitIndex:            0,
 			fileName:               []string{"test999.txt"},