summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2024-01-23 17:03:29 +1100
committerJesse Duffield <jessedduffield@gmail.com>2024-01-23 17:23:56 +1100
commit41d5f4dbb5571db2b8812e9000af78cfab0e7d05 (patch)
tree0d353aaaf1ed34f9452b1dbc0fa6251e62e51a20
parentf0de8801368c388b0065008a769b6cfc2ff5205e (diff)
Disallow updating non-standard TODO lines when rebasing
-rw-r--r--pkg/gui/controllers/local_commits_controller.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go
index e1d20b554..2062907f0 100644
--- a/pkg/gui/controllers/local_commits_controller.go
+++ b/pkg/gui/controllers/local_commits_controller.go
@@ -1028,7 +1028,7 @@ func (self *LocalCommitsController) midRebaseCommandEnabled(selectedCommits []*m
return &types.DisabledReason{Text: self.c.Tr.MustSelectTodoCommits}
}
- if commit.Action == models.ActionConflict {
+ if !isChangeOfRebaseTodoAllowed(commit.Action) {
return &types.DisabledReason{Text: self.c.Tr.ChangingThisActionIsNotAllowed}
}
}
@@ -1036,6 +1036,24 @@ func (self *LocalCommitsController) midRebaseCommandEnabled(selectedCommits []*m
return nil
}
+// These actions represent standard things you might want to do with a commit,
+// as opposed to TODO actions like 'merge', 'update-ref', etc.
+var standardActions = []todo.TodoCommand{
+ todo.Pick,
+ todo.Drop,
+ todo.Edit,
+ todo.Fixup,
+ todo.Squash,
+ todo.Reword,
+}
+
+func isChangeOfRebaseTodoAllowed(oldAction todo.TodoCommand) bool {
+ // Only allow updating a standard action, meaning we disallow
+ // updating a merge commit or update ref commit (until we decide what would be sensible
+ // to do in those cases)
+ return lo.Contains(standardActions, oldAction)
+}
+
func (self *LocalCommitsController) pickEnabled(selectedCommits []*models.Commit, startIdx int, endIdx int) *types.DisabledReason {
if !self.isRebasing() {
// if not rebasing, we're going to do a pull so we don't care about the selection