mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-23 00:39:13 +02:00
Don't allow changing the type of certain rebase todos
We already show "merge" todo entries when starting an interactive rebase with --rebase-merges outside of lazygit. Changing the type of a merge entry to "pick" or "edit" doesn't make sense and shouldn't be allowed. Earlier in this branch we have started to show "update-ref" entries, these can't be changed either (they can be moved, though). You might argue that it should be possible to change them to "drop", but in the case of "update-ref" this doesn't make sense either, because "drop" needs a Sha and we don't have one here. Also, you would then be able to later change it back to "pick", so we would have to remember that this isn't allowed for this particular drop entry; that's messy, so just disallow all editing.
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -348,6 +349,10 @@ func (self *LocalCommitsController) handleMidRebaseCommand(action todo.TodoComma
|
|||||||
return true, self.c.ErrorMsg(self.c.Tr.LcRewordNotSupported)
|
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.LogAction("Update rebase TODO")
|
||||||
self.c.LogCommand(
|
self.c.LogCommand(
|
||||||
fmt.Sprintf("Updating rebase action of commit %s to '%s'", commit.ShortSha(), action.String()),
|
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 {
|
func (self *LocalCommitsController) isHeadCommit() bool {
|
||||||
return models.IsHeadCommit(self.model.Commits, self.context().GetSelectedLineIdx())
|
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)
|
||||||
|
}
|
||||||
|
@ -219,6 +219,7 @@ type TranslationSet struct {
|
|||||||
YouAreHere string
|
YouAreHere string
|
||||||
YouDied string
|
YouDied string
|
||||||
LcRewordNotSupported string
|
LcRewordNotSupported string
|
||||||
|
LcChangingThisActionIsNotAllowed string
|
||||||
LcCherryPickCopy string
|
LcCherryPickCopy string
|
||||||
LcCherryPickCopyRange string
|
LcCherryPickCopyRange string
|
||||||
LcPasteCommits string
|
LcPasteCommits string
|
||||||
@ -887,6 +888,7 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
YouAreHere: "YOU ARE HERE",
|
YouAreHere: "YOU ARE HERE",
|
||||||
YouDied: "YOU DIED!",
|
YouDied: "YOU DIED!",
|
||||||
LcRewordNotSupported: "rewording commits while interactively rebasing is not currently supported",
|
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)",
|
LcCherryPickCopy: "copy commit (cherry-pick)",
|
||||||
LcCherryPickCopyRange: "copy commit range (cherry-pick)",
|
LcCherryPickCopyRange: "copy commit range (cherry-pick)",
|
||||||
LcPasteCommits: "paste commits (cherry-pick)",
|
LcPasteCommits: "paste commits (cherry-pick)",
|
||||||
|
Reference in New Issue
Block a user