mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Fix order of fixup base commits shown in ctrl-f error message
This commit is contained in:
parent
c16b4b1d2e
commit
e2b3601c57
|
|
@ -114,10 +114,7 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
|
|||
// If there are multiple commits that could be the base commit, list
|
||||
// them in the error message. But only the candidates from the current
|
||||
// branch, not including any that are already merged.
|
||||
subjects, err := self.c.Git().Commit.GetHashesAndCommitMessagesFirstLine(hashGroups[NOT_MERGED])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
subjects := self.getHashesAndSubjects(commits, hashGroups[NOT_MERGED])
|
||||
message := lo.Ternary(hasStagedChanges,
|
||||
self.c.Tr.MultipleBaseCommitsFoundStaged,
|
||||
self.c.Tr.MultipleBaseCommitsFoundUnstaged)
|
||||
|
|
@ -146,6 +143,23 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
|
|||
})
|
||||
}
|
||||
|
||||
func (self *FixupHelper) getHashesAndSubjects(commits []*models.Commit, hashes []string) string {
|
||||
// This is called only for the NOT_MERGED commits, and we know that all of them are contained in
|
||||
// the commits slice.
|
||||
commitsSet := set.NewFromSlice(hashes)
|
||||
subjects := make([]string, 0, len(hashes))
|
||||
for _, c := range commits {
|
||||
if commitsSet.Includes(c.Hash()) {
|
||||
subjects = append(subjects, fmt.Sprintf("%s %s", c.ShortRefName(), c.Name))
|
||||
commitsSet.Remove(c.Hash())
|
||||
if commitsSet.Len() == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return strings.Join(subjects, "\n")
|
||||
}
|
||||
|
||||
func (self *FixupHelper) getDiff() (string, bool, error) {
|
||||
args := []string{"-U0", "--ignore-submodules=all", "HEAD", "--"}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ var FindBaseCommitForFixup = NewIntegrationTest(NewIntegrationTestArgs{
|
|||
Title(Equals("Error")).
|
||||
Content(
|
||||
MatchesRegexp("Multiple base commits found.*\n\n" +
|
||||
".*2nd commit\n" +
|
||||
".*3rd commit"),
|
||||
".*3rd commit\n" +
|
||||
".*2nd commit"),
|
||||
).
|
||||
Confirm()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue