summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-03-24 09:25:51 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-24 09:45:27 +1100
commitf113ff21bff22bc9e3dc683a4f52822233b76b95 (patch)
tree44a9e0805391296d460333ef415cc210f89140ca /pkg/gui/controllers
parent12ecd665c8f69e45e00629b05c2b3af72f3e3b51 (diff)
add confirmation before performing undo or redo action
Diffstat (limited to 'pkg/gui/controllers')
-rw-r--r--pkg/gui/controllers/undo_controller.go60
1 files changed, 44 insertions, 16 deletions
diff --git a/pkg/gui/controllers/undo_controller.go b/pkg/gui/controllers/undo_controller.go
index bfd6dc444..ba54f4201 100644
--- a/pkg/gui/controllers/undo_controller.go
+++ b/pkg/gui/controllers/undo_controller.go
@@ -1,6 +1,8 @@
package controllers
import (
+ "fmt"
+
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
@@ -83,17 +85,30 @@ func (self *UndoController) reflogUndo() error {
switch action.kind {
case COMMIT, REBASE:
- self.c.LogAction(self.c.Tr.Actions.Undo)
- return true, self.hardResetWithAutoStash(action.from, hardResetOptions{
- EnvVars: undoEnvVars,
- WaitingStatus: undoingStatus,
+ return true, self.c.Ask(types.AskOpts{
+ Title: self.c.Tr.Actions.Undo,
+ Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, action.from),
+ HandleConfirm: func() error {
+ self.c.LogAction(self.c.Tr.Actions.Undo)
+ return self.hardResetWithAutoStash(action.from, hardResetOptions{
+ EnvVars: undoEnvVars,
+ WaitingStatus: undoingStatus,
+ })
+ },
})
case CHECKOUT:
- self.c.LogAction(self.c.Tr.Actions.Undo)
- return true, self.helpers.Refs.CheckoutRef(action.from, types.CheckoutRefOptions{
- EnvVars: undoEnvVars,
- WaitingStatus: undoingStatus,
+ return true, self.c.Ask(types.AskOpts{
+ Title: self.c.Tr.Actions.Undo,
+ Prompt: fmt.Sprintf(self.c.Tr.CheckoutPrompt, action.from),
+ HandleConfirm: func() error {
+ self.c.LogAction(self.c.Tr.Actions.Undo)
+ return self.helpers.Refs.CheckoutRef(action.from, types.CheckoutRefOptions{
+ EnvVars: undoEnvVars,
+ WaitingStatus: undoingStatus,
+ })
+ },
})
+
case CURRENT_REBASE:
// do nothing
}
@@ -121,16 +136,29 @@ func (self *UndoController) reflogRedo() error {
switch action.kind {
case COMMIT, REBASE:
- self.c.LogAction(self.c.Tr.Actions.Redo)
- return true, self.hardResetWithAutoStash(action.to, hardResetOptions{
- EnvVars: redoEnvVars,
- WaitingStatus: redoingStatus,
+ return true, self.c.Ask(types.AskOpts{
+ Title: self.c.Tr.Actions.Redo,
+ Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, action.to),
+ HandleConfirm: func() error {
+ self.c.LogAction(self.c.Tr.Actions.Redo)
+ return self.hardResetWithAutoStash(action.to, hardResetOptions{
+ EnvVars: redoEnvVars,
+ WaitingStatus: redoingStatus,
+ })
+ },
})
+
case CHECKOUT:
- self.c.LogAction(self.c.Tr.Actions.Redo)
- return true, self.helpers.Refs.CheckoutRef(action.to, types.CheckoutRefOptions{
- EnvVars: redoEnvVars,
- WaitingStatus: redoingStatus,
+ return true, self.c.Ask(types.AskOpts{
+ Title: self.c.Tr.Actions.Redo,
+ Prompt: fmt.Sprintf(self.c.Tr.CheckoutPrompt, action.to),
+ HandleConfirm: func() error {
+ self.c.LogAction(self.c.Tr.Actions.Redo)
+ return self.helpers.Refs.CheckoutRef(action.to, types.CheckoutRefOptions{
+ EnvVars: redoEnvVars,
+ WaitingStatus: redoingStatus,
+ })
+ },
})
case CURRENT_REBASE:
// do nothing