1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-07 01:09:45 +02:00

Use ConfirmIf where applicable

This commit is contained in:
Stefan Haller
2025-07-06 14:25:13 +02:00
parent c35f907f9f
commit 2c3b25ae62
11 changed files with 143 additions and 234 deletions

View File

@ -107,32 +107,23 @@ func (self *StashController) context() *context.StashContext {
}
func (self *StashController) handleStashApply(stashEntry *models.StashEntry) error {
apply := func() error {
self.c.LogAction(self.c.Tr.Actions.Stash)
err := self.c.Git().Stash.Apply(stashEntry.Index)
self.postStashRefresh()
if err != nil {
return err
}
if self.c.UserConfig().Gui.SwitchToFilesAfterStashApply {
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
}
return nil
}
if self.c.UserConfig().Gui.SkipStashWarning {
return apply()
}
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.StashApply,
Prompt: self.c.Tr.SureApplyStashEntry,
HandleConfirm: func() error {
return apply()
},
})
return nil
return self.c.ConfirmIf(!self.c.UserConfig().Gui.SkipStashWarning,
types.ConfirmOpts{
Title: self.c.Tr.StashApply,
Prompt: self.c.Tr.SureApplyStashEntry,
HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.Stash)
err := self.c.Git().Stash.Apply(stashEntry.Index)
self.postStashRefresh()
if err != nil {
return err
}
if self.c.UserConfig().Gui.SwitchToFilesAfterStashApply {
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
}
return nil
},
})
}
func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error {