Disable fixup/squash for merge commits

This commit is contained in:
Stefan Haller 2024-11-30 15:28:07 +01:00
parent 75d2fb1df2
commit bd0d9ef259
2 changed files with 7 additions and 1 deletions

View file

@ -1358,11 +1358,15 @@ func (self *LocalCommitsController) canFindCommitForSquashFixupsInCurrentBranch(
return nil
}
func (self *LocalCommitsController) canSquashOrFixup(_selectedCommits []*models.Commit, startIdx int, endIdx int) *types.DisabledReason {
func (self *LocalCommitsController) canSquashOrFixup(selectedCommits []*models.Commit, startIdx int, endIdx int) *types.DisabledReason {
if endIdx >= len(self.c.Model().Commits)-1 {
return &types.DisabledReason{Text: self.c.Tr.CannotSquashOrFixupFirstCommit}
}
if lo.SomeBy(selectedCommits, func(c *models.Commit) bool { return c.IsMerge() }) {
return &types.DisabledReason{Text: self.c.Tr.CannotSquashOrFixupMergeCommit}
}
return nil
}

View file

@ -140,6 +140,7 @@ type TranslationSet struct {
Quit string
SquashTooltip string
CannotSquashOrFixupFirstCommit string
CannotSquashOrFixupMergeCommit string
Fixup string
FixupTooltip string
SureFixupThisCommit string
@ -1135,6 +1136,7 @@ func EnglishTranslationSet() *TranslationSet {
UpdateRefHere: "Update branch '{{.ref}}' here",
ExecCommandHere: "Execute the following command here:",
CannotSquashOrFixupFirstCommit: "There's no commit below to squash into",
CannotSquashOrFixupMergeCommit: "Cannot squash or fixup a merge commit",
Fixup: "Fixup",
SureFixupThisCommit: "Are you sure you want to 'fixup' the selected commit(s) into the commit below?",
SureSquashThisCommit: "Are you sure you want to squash the selected commit(s) into the commit below?",