diff --git a/pkg/gui/controllers/undo_controller.go b/pkg/gui/controllers/undo_controller.go index 42e28a09e2c..198aa7d7bcb 100644 --- a/pkg/gui/controllers/undo_controller.go +++ b/pkg/gui/controllers/undo_controller.go @@ -118,7 +118,7 @@ func (self *UndoController) reflogUndo() error { case CHECKOUT: self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Undo, - Prompt: fmt.Sprintf(self.c.Tr.CheckoutPrompt, action.from), + Prompt: fmt.Sprintf(self.c.Tr.CheckoutAutostashPrompt, action.from), HandleConfirm: func() error { self.c.LogAction(self.c.Tr.Actions.Undo) return self.c.Helpers().Refs.CheckoutRef(action.from, types.CheckoutRefOptions{ @@ -172,7 +172,7 @@ func (self *UndoController) reflogRedo() error { case CHECKOUT: self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Redo, - Prompt: fmt.Sprintf(self.c.Tr.CheckoutPrompt, action.to), + Prompt: fmt.Sprintf(self.c.Tr.CheckoutAutostashPrompt, action.to), HandleConfirm: func() error { self.c.LogAction(self.c.Tr.Actions.Redo) return self.c.Helpers().Refs.CheckoutRef(action.to, types.CheckoutRefOptions{ @@ -257,31 +257,23 @@ func (self *UndoController) hardResetWithAutoStash(commitHash string, options ha return self.c.Helpers().Refs.ResetToRef(commitHash, "hard", options.EnvVars) } - // if we have any modified tracked files we need to ask the user if they want us to stash for them + // if we have any modified tracked files we need to auto-stash dirtyWorkingTree := self.c.Helpers().WorkingTree.IsWorkingTreeDirty() if dirtyWorkingTree { - // offer to autostash changes - self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.AutoStashTitle, - Prompt: self.c.Tr.AutoStashPrompt, - HandleConfirm: func() error { - return self.c.WithWaitingStatus(options.WaitingStatus, func(gocui.Task) error { - if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + commitHash); err != nil { - return err - } - if err := reset(); err != nil { - return err - } - - err := self.c.Git().Stash.Pop(0) - if err != nil { - return err - } - return self.c.Refresh(types.RefreshOptions{}) - }) - }, + return self.c.WithWaitingStatus(options.WaitingStatus, func(gocui.Task) error { + if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + commitHash); err != nil { + return err + } + if err := reset(); err != nil { + return err + } + + err := self.c.Git().Stash.Pop(0) + if err != nil { + return err + } + return self.c.Refresh(types.RefreshOptions{}) }) - return nil } return self.c.WithWaitingStatus(options.WaitingStatus, func(gocui.Task) error { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index fd15d23f535..3efe269b262 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -732,7 +732,7 @@ type TranslationSet struct { ConfirmRevertCommit string RewordInEditorTitle string RewordInEditorPrompt string - CheckoutPrompt string + CheckoutAutostashPrompt string HardResetAutostashPrompt string SoftResetPrompt string UpstreamGone string @@ -1747,7 +1747,7 @@ func EnglishTranslationSet() *TranslationSet { RewordInEditorPrompt: "Are you sure you want to reword this commit in your editor?", HardResetAutostashPrompt: "Are you sure you want to hard reset to '%s'? An auto-stash will be performed if necessary.", SoftResetPrompt: "Are you sure you want to soft reset to '%s'?", - CheckoutPrompt: "Are you sure you want to checkout '%s'?", + CheckoutAutostashPrompt: "Are you sure you want to checkout '%s'? An auto-stash will be performed if necessary.", UpstreamGone: "(upstream gone)", NukeDescription: "If you want to make all the changes in the worktree go away, this is the way to do it. If there are dirty submodule changes this will stash those changes in the submodule(s).", DiscardStagedChangesDescription: "This will create a new stash entry containing only staged files and then drop it, so that the working tree is left with only unstaged changes", diff --git a/pkg/integration/tests/undo/undo_commit.go b/pkg/integration/tests/undo/undo_commit.go index df79c6220c0..a636385ebf1 100644 --- a/pkg/integration/tests/undo/undo_commit.go +++ b/pkg/integration/tests/undo/undo_commit.go @@ -39,13 +39,6 @@ var UndoCommit = NewIntegrationTest(NewIntegrationTestArgs{ Confirm() } - confirmAutoSquash := func() { - t.ExpectPopup().Confirmation(). - Title(Equals("Autostash?")). - Content(MatchesRegexp(`You must stash and pop your changes to bring them across\. Do this automatically\? \(enter\/esc\)`)). - Confirm() - } - t.Views().Files(). Lines( Contains(" M other-file"), @@ -71,7 +64,6 @@ var UndoCommit = NewIntegrationTest(NewIntegrationTestArgs{ t.Views().Commits().Focus(). Press(keys.Universal.Redo). Tap(confirmRedo). - Tap(confirmAutoSquash). Lines( Contains("two").IsSelected(), Contains("one"), @@ -102,8 +94,7 @@ var UndoCommit = NewIntegrationTest(NewIntegrationTestArgs{ Contains(" M other-file"), ). Press(keys.Universal.Redo). - Tap(confirmRedo). - Tap(confirmAutoSquash) + Tap(confirmRedo) t.Views().Commits(). Lines(