summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-08 14:17:54 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-08 22:54:52 +1000
commit26ca41a40e3ee79a3e84542ff6cf3fd3f2745679 (patch)
tree42df8e770a7a10147e5716d802ad90ba2e01f987 /pkg/gui/gui.go
parent6c4e7ee9729ccfd65ac03073a37bd110a61be432 (diff)
Handle pending actions properly in git commands that require credentials
I don't know if this is a hack or not: we run a git command and increment the pending action count to 1 but at some point the command requests a username or password, so we need to prompt the user to enter that. At that point we don't want to say that there is a pending action, so we decrement the action count before prompting the user and then re-increment it again afterward. Given that we panic when the counter goes below zero, it's important that it's not zero when we run the git command (should be impossible anyway). I toyed with a different approach using channels and a long-running goroutine that handles all commands that request credentials but it feels over-engineered compared to this commit's approach.
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 92deee1a0..5bba6b967 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -487,6 +487,8 @@ func NewGui(
gui.LogCommand,
gui.getCmdWriter,
credentialsHelper.PromptUserForCredential,
+ func() { gui.g.IncrementBusyCount() },
+ func() { gui.g.DecrementBusyCount() },
)
osCommand := oscommands.NewOSCommand(cmn, config, oscommands.GetPlatform(), guiIO)