From c6d20c876ecb11b2476eb9b173734f6af3aff06c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 31 Jan 2024 12:02:24 +0100 Subject: [PATCH] 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. --- pkg/gui/controllers/local_commits_controller.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 0c55ffa44..e6b8bc801 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -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)