Skip to content

Commit

Permalink
New PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Lanata <[email protected]>
  • Loading branch information
gabriellanata committed Jan 16, 2025
1 parent 01b134a commit 87e0d46
Showing 1 changed file with 20 additions and 33 deletions.
53 changes: 20 additions & 33 deletions pkg/gui/controllers/undo_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,31 @@ func (self *UndoController) reflogUndo() error {
}

switch action.kind {
case COMMIT:
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.Actions.Undo,
Prompt: fmt.Sprintf(self.c.Tr.SoftResetAutostashPrompt, action.from),
HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.Undo)
return self.resetWithAutoStash(action.from, resetOptions{
Mode: "soft",
EnvVars: undoEnvVars,
WaitingStatus: undoingStatus,
})
},
})
return true, nil
case COMMIT, REBASE:
var resetMode string
switch action.kind {
case COMMIT:
resetMode = "soft"
case REBASE:
resetMode = "hard"
}

var resetPrompt string
switch resetMode {
case "hard":
resetPrompt = self.c.Tr.HardResetAutostashPrompt
case "soft":
resetPrompt = self.c.Tr.SoftResetAutostashPrompt
}

case REBASE:
// 3. Use those in the confirm step
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.Actions.Undo,
Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, action.from),
Prompt: fmt.Sprintf(resetPrompt, action.from),
HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.Undo)
return self.resetWithAutoStash(action.from, resetOptions{
Mode: "hard",
Mode: resetMode,
EnvVars: undoEnvVars,
WaitingStatus: undoingStatus,
})
Expand Down Expand Up @@ -158,22 +160,7 @@ func (self *UndoController) reflogRedo() error {
}

switch action.kind {
case COMMIT:
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.Actions.Redo,
Prompt: fmt.Sprintf(self.c.Tr.SoftResetAutostashPrompt, action.to),
HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.Redo)
return self.resetWithAutoStash(action.to, resetOptions{
Mode: "soft",
EnvVars: redoEnvVars,
WaitingStatus: redoingStatus,
})
},
})
return true, nil

case REBASE:
case COMMIT, REBASE:
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.Actions.Redo,
Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, action.to),
Expand Down

0 comments on commit 87e0d46

Please sign in to comment.