From 238fdd573cf35a3bd54c5eb2f825901cf371469d Mon Sep 17 00:00:00 2001 From: Dawid Pietrykowski Date: Sat, 12 Jul 2025 00:58:04 +0200 Subject: [PATCH] Add confirmation for nuking the working tree --- .../controllers/workspace_reset_controller.go | 28 ++++++++++++------- pkg/i18n/english.go | 2 ++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index 9865e7796..de6fc4577 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -31,18 +31,26 @@ func (self *FilesController) createResetMenu() error { red.Sprint(nukeStr), }, OnPress: func() error { - self.c.LogAction(self.c.Tr.Actions.NukeWorkingTree) - if err := self.c.Git().WorkingTree.ResetAndClean(); err != nil { - return err - } + self.c.Confirm( + types.ConfirmOpts{ + Title: self.c.Tr.Actions.NukeWorkingTree, + Prompt: self.c.Tr.NukeTreeConfirmation, + HandleConfirm: func() error { + self.c.LogAction(self.c.Tr.Actions.NukeWorkingTree) + if err := self.c.Git().WorkingTree.ResetAndClean(); err != nil { + return err + } - if self.c.UserConfig().Gui.AnimateExplosion { - self.animateExplosion() - } + if self.c.UserConfig().Gui.AnimateExplosion { + self.animateExplosion() + } - self.c.Refresh( - types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}, - ) + self.c.Refresh( + types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}, + ) + return nil + }, + }) return nil }, Key: 'x', diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 2b307780e..6eba8d5ef 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -782,6 +782,7 @@ type TranslationSet struct { SoftResetPrompt string UpstreamGone string NukeDescription string + NukeTreeConfirmation string DiscardStagedChangesDescription string EmptyOutput string Patch string @@ -1832,6 +1833,7 @@ func EnglishTranslationSet() *TranslationSet { 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).", + NukeTreeConfirmation: "Are you sure you want to nuke the working tree? This will discard all changes in the worktree (staged, unstaged and untracked), which is not undoable.", 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", EmptyOutput: "", Patch: "Patch",