diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 48fafd4e6..4610aed12 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -9,6 +9,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/samber/lo" ) type ( @@ -348,6 +349,10 @@ func (self *LocalCommitsController) handleMidRebaseCommand(action todo.TodoComma return true, self.c.ErrorMsg(self.c.Tr.LcRewordNotSupported) } + if allowed := isChangeOfRebaseTodoAllowed(action); !allowed { + return true, self.c.ErrorMsg(self.c.Tr.LcChangingThisActionIsNotAllowed) + } + self.c.LogAction("Update rebase TODO") self.c.LogCommand( fmt.Sprintf("Updating rebase action of commit %s to '%s'", commit.ShortSha(), action.String()), @@ -759,3 +764,16 @@ func (self *LocalCommitsController) paste() error { func (self *LocalCommitsController) isHeadCommit() bool { return models.IsHeadCommit(self.model.Commits, self.context().GetSelectedLineIdx()) } + +func isChangeOfRebaseTodoAllowed(action todo.TodoCommand) bool { + allowedActions := []todo.TodoCommand{ + todo.Pick, + todo.Drop, + todo.Edit, + todo.Fixup, + todo.Squash, + todo.Reword, + } + + return lo.Contains(allowedActions, action) +} diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 7b6642882..80179f365 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -219,6 +219,7 @@ type TranslationSet struct { YouAreHere string YouDied string LcRewordNotSupported string + LcChangingThisActionIsNotAllowed string LcCherryPickCopy string LcCherryPickCopyRange string LcPasteCommits string @@ -887,6 +888,7 @@ func EnglishTranslationSet() TranslationSet { YouAreHere: "YOU ARE HERE", YouDied: "YOU DIED!", LcRewordNotSupported: "rewording commits while interactively rebasing is not currently supported", + LcChangingThisActionIsNotAllowed: "changing this kind of rebase todo entry is not allowed", LcCherryPickCopy: "copy commit (cherry-pick)", LcCherryPickCopyRange: "copy commit range (cherry-pick)", LcPasteCommits: "paste commits (cherry-pick)",