Skip to content

Commit 5e542c3

Browse files
committed
Filter out merge commits when generating todo changes in InteractiveRebase
We will need this because under some conditions we are going to use this function to edit a range of commits, and we can't set merge commits to "edit". This corresponds to the code in startInteractiveRebaseWithEdit which has similar logic. It is a bit unfortunate that we will have these two different ways of setting todos to edit: startInteractiveRebaseWithEdit does it after stopping in the rebase, in the Then function of its refresh, but InteractiveRebase does it in the daemon with a ChangeTodoActionsInstruction. It still makes sense though, given how InteractiveRebase works. This not only affects "edit", but also "drop", "fixup", and "squash". Previously, when trying to use these for a range selection that includes a merge commit, they would fail with the cryptic error message "Some todos not found in git-rebase-todo"; now they simply exclude the merge commit. I'm not sure if one is better or worse than the other, and we should probably simply disable the commands when a merge commit is selected, but that's out of scope in this PR.
1 parent 0b33634 commit 5e542c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/commands/git_commands/rebase.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, startIdx
145145

146146
baseHashOrRoot := getBaseHashOrRoot(commits, baseIndex)
147147

148-
changes := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) daemon.ChangeTodoAction {
148+
changes := lo.FilterMap(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) (daemon.ChangeTodoAction, bool) {
149149
return daemon.ChangeTodoAction{
150150
Hash: commit.Hash,
151151
NewAction: action,
152-
}
152+
}, !commit.IsMerge()
153153
})
154154

155155
self.os.LogCommand(logTodoChanges(changes), false)

0 commit comments

Comments
 (0)