1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

Add confirmation for nuking the working tree

This commit is contained in:
Dawid Pietrykowski
2025-07-12 00:58:04 +02:00
parent 1795cb9315
commit 238fdd573c
2 changed files with 20 additions and 10 deletions

View File

@ -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',

View File

@ -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: "<Empty output>",
Patch: "Patch",