From c765da10f53c2710febc2c8bed0a7a5006bac4c0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 16 Mar 2025 14:36:41 +0100 Subject: [PATCH] Allow passing refresh scope to WithGpgHandling --- pkg/gui/controllers/helpers/amend_helper.go | 2 +- pkg/gui/controllers/helpers/gpg_helper.go | 12 ++++++------ pkg/gui/controllers/helpers/tags_helper.go | 2 +- pkg/gui/controllers/helpers/working_tree_helper.go | 2 +- pkg/gui/controllers/local_commits_controller.go | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/gui/controllers/helpers/amend_helper.go b/pkg/gui/controllers/helpers/amend_helper.go index 8a0a9817e..03c6bb485 100644 --- a/pkg/gui/controllers/helpers/amend_helper.go +++ b/pkg/gui/controllers/helpers/amend_helper.go @@ -20,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, git_commands.CommitGpgSign, 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 5a17e819c..da87d1e6a 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 { // 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, configKey git_commands.GpgConfigKey, waitingStatus string, onSuccess func() error) error { +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) @@ -32,20 +32,20 @@ func (self *GpgHelper) WithGpgHandling(cmdObj oscommands.ICmdObj, configKey git_ 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, ) @@ -57,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 ebcc70a3f..b247ad838 100644 --- a/pkg/gui/controllers/helpers/tags_helper.go +++ b/pkg/gui/controllers/helpers/tags_helper.go @@ -36,7 +36,7 @@ func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error { return self.gpg.WithGpgHandling(command, git_commands.TagGpgSign, self.c.Tr.CreatingTag, func() error { self.commitsHelper.OnCommitSuccess() 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 7c077bcfc..e85e6702e 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -116,7 +116,7 @@ func (self *WorkingTreeHelper) handleCommit(summary string, description string, 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 0ed346824..c459f4261 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -414,7 +414,7 @@ func (self *LocalCommitsController) handleReword(summary string, description str // we've selected the top commit so no rebase is required return self.c.Helpers().GPG.WithGpgHandling(self.c.Git().Commit.RewordLastCommit(summary, description), git_commands.CommitGpgSign, - self.c.Tr.RewordingStatus, nil) + self.c.Tr.RewordingStatus, nil, nil) } return self.c.WithWaitingStatus(self.c.Tr.RewordingStatus, func(gocui.Task) error {