From 52da806c5713e4bdbc3be05bc1f78124950c7e9f Mon Sep 17 00:00:00 2001 From: Chris McDonnell Date: Thu, 13 Mar 2025 23:59:19 -0400 Subject: [PATCH] refactor: Rename UsingGpg to make room for Gpg Tag logic --- pkg/commands/git_commands/config.go | 7 ++++--- pkg/commands/git_commands/patch.go | 2 +- pkg/commands/git_commands/rebase.go | 4 ++-- pkg/gui/controllers/helpers/gpg_helper.go | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/commands/git_commands/config.go b/pkg/commands/git_commands/config.go index 5ea8f91d7..865315f11 100644 --- a/pkg/commands/git_commands/config.go +++ b/pkg/commands/git_commands/config.go @@ -57,9 +57,10 @@ 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 { +// NeedsGpgSubprocessForCommit tells us whether the user has gpg enabled for commit actions +// 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) NeedsGpgSubprocessForCommit() bool { overrideGpg := self.UserConfig().Git.OverrideGpg if overrideGpg { return false diff --git a/pkg/commands/git_commands/patch.go b/pkg/commands/git_commands/patch.go index 830ee2cb6..36e094337 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 757257750..155455a34 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/gui/controllers/helpers/gpg_helper.go b/pkg/gui/controllers/helpers/gpg_helper.go index 6974e1c5c..610442b33 100644 --- a/pkg/gui/controllers/helpers/gpg_helper.go +++ b/pkg/gui/controllers/helpers/gpg_helper.go @@ -23,7 +23,7 @@ func NewGpgHelper(c *HelperCommon) *GpgHelper { // 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() + useSubprocess := self.c.Git().Config.NeedsGpgSubprocessForCommit() if useSubprocess { success, err := self.c.RunSubprocess(cmdObj) if success && onSuccess != nil {