Extract common code to a helper method

This should arguably have been done in b133318b40 already; it's becoming more
important now because we're going to extend the common code with more logic in
the next commit.
This commit is contained in:
Stefan Haller 2024-01-31 12:02:24 +01:00
parent 3e3b902228
commit c6d20c876e

View file

@ -847,11 +847,7 @@ func (self *LocalCommitsController) squashFixupCommits() error {
}
func (self *LocalCommitsController) squashAllFixupsAboveSelectedCommit(commit *models.Commit) error {
return self.c.WithWaitingStatus(self.c.Tr.SquashingStatus, func(gocui.Task) error {
self.c.LogAction(self.c.Tr.Actions.SquashAllAboveFixupCommits)
err := self.c.Git().Rebase.SquashAllAboveFixupCommits(commit)
return self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err)
})
return self.squashFixupsImpl(commit)
}
func (self *LocalCommitsController) squashAllFixupsInCurrentBranch() error {
@ -860,6 +856,10 @@ func (self *LocalCommitsController) squashAllFixupsInCurrentBranch() error {
return self.c.Error(err)
}
return self.squashFixupsImpl(commit)
}
func (self *LocalCommitsController) squashFixupsImpl(commit *models.Commit) error {
return self.c.WithWaitingStatus(self.c.Tr.SquashingStatus, func(gocui.Task) error {
self.c.LogAction(self.c.Tr.Actions.SquashAllAboveFixupCommits)
err := self.c.Git().Rebase.SquashAllAboveFixupCommits(commit)