mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-06 23:46:13 +02:00
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.
This commit is contained in:
parent
2c9bca8b57
commit
c1a65546ad
@ -76,9 +76,7 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
|
|||||||
return fmt.Errorf("%s\n\n%s", message, subjects)
|
return fmt.Errorf("%s\n\n%s", message, subjects)
|
||||||
}
|
}
|
||||||
|
|
||||||
commit, index, ok := lo.FindIndexOf(self.c.Model().Commits, func(commit *models.Commit) bool {
|
commit, index, ok := self.findCommit(hashes[0])
|
||||||
return commit.Hash == hashes[0]
|
|
||||||
})
|
|
||||||
if !ok {
|
if !ok {
|
||||||
commits := self.c.Model().Commits
|
commits := self.c.Model().Commits
|
||||||
if commits[len(commits)-1].Status == models.StatusMerged {
|
if commits[len(commits)-1].Status == models.StatusMerged {
|
||||||
@ -221,3 +219,9 @@ func (self *FixupHelper) blameDeletedLines(deletedLineHunks []*hunk) ([]string,
|
|||||||
|
|
||||||
return result.ToSlice(), errg.Wait()
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user