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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user