summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-05-20 19:01:05 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-06-01 08:31:18 +0200
commitc1a65546ad7c881e8e34aabafe11161569be3dba (patch)
treeb4d0d8fc07f0724a60e1c7d5e8b1b2ac489da7dd /pkg
parent2c9bca8b579fb2c3f541361ae40713a41d2ba13c (diff)
Extract a function findCommit
It's not much code, but it turns three lines of code into one, and since we need to do this a few more times in the next commit, it's worth it.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/controllers/helpers/fixup_helper.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/gui/controllers/helpers/fixup_helper.go b/pkg/gui/controllers/helpers/fixup_helper.go
index f57e8f2f9..e816f425d 100644
--- a/pkg/gui/controllers/helpers/fixup_helper.go
+++ b/pkg/gui/controllers/helpers/fixup_helper.go
@@ -76,9 +76,7 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
return fmt.Errorf("%s\n\n%s", message, subjects)
}
- commit, index, ok := lo.FindIndexOf(self.c.Model().Commits, func(commit *models.Commit) bool {
- return commit.Hash == hashes[0]
- })
+ commit, index, ok := self.findCommit(hashes[0])
if !ok {
commits := self.c.Model().Commits
if commits[len(commits)-1].Status == models.StatusMerged {
@@ -221,3 +219,9 @@ func (self *FixupHelper) blameDeletedLines(deletedLineHunks []*hunk) ([]string,
return result.ToSlice(), errg.Wait()
}
+
+func (self *FixupHelper) findCommit(hash string) (*models.Commit, int, bool) {
+ return lo.FindIndexOf(self.c.Model().Commits, func(commit *models.Commit) bool {
+ return commit.Hash == hash
+ })
+}