1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-09 01:17:06 +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

@ -128,32 +128,22 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
// and that's the one we want to select.
_, index, _ := self.findCommit(commits, hashGroups[NOT_MERGED][0])
doIt := func() error {
if !hasStagedChanges {
if err := self.c.Git().WorkingTree.StageAll(); err != nil {
return err
return self.c.ConfirmIf(warnAboutAddedLines, types.ConfirmOpts{
Title: self.c.Tr.FindBaseCommitForFixup,
Prompt: self.c.Tr.HunksWithOnlyAddedLinesWarning,
HandleConfirm: func() error {
if !hasStagedChanges {
if err := self.c.Git().WorkingTree.StageAll(); err != nil {
return err
}
self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.FILES}})
}
self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.FILES}})
}
self.c.Contexts().LocalCommits.SetSelection(index)
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
return nil
}
if warnAboutAddedLines {
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.FindBaseCommitForFixup,
Prompt: self.c.Tr.HunksWithOnlyAddedLinesWarning,
HandleConfirm: func() error {
return doIt()
},
})
return nil
}
return doIt()
self.c.Contexts().LocalCommits.SetSelection(index)
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
return nil
},
})
}
func (self *FixupHelper) getDiff() (string, bool, error) {