Add a test showing that moving commits of two branches breaks the stack

If a range of selected commits spans the boundary between two branches
of a stack, moving it outside of a rebase moves each of its commits
separately past the next commit. The update-ref todo inside the range
stays behind. In the test, branch2 is left without any commits of its
own after moving the range up, and its commits now belong to branch3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan HallerandClaude Opus 5.5 committed 2026-11-12 15:26:10 +01:00
1 parent 39252fea94
commit f8877eef26
2 files changed
+59

No files matched your search

@@ -0,0 +1,58 @@
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var MoveRangeSpanningBranchBoundaryOutsideRebase = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Move a range of commits that spans a branch boundary in a stack of branches",
ExtraCmdArgs: []string{},
Skip: false,
GitVersion: AtLeast("2.38.0"),
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.MainBranches = []string{"master"}
config.GetUserConfig().Git.Log.ShowGraph = "never"
},
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(1).
NewBranch("branch1").
CreateNCommitsStartingAt(2, 2).
NewBranch("branch2").
CreateNCommitsStartingAt(2, 4).
NewBranch("branch3").
CreateNCommitsStartingAt(2, 6)
shell.SetConfig("rebase.updateRefs", "true")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("CI commit-07").IsSelected(),
Contains("CI commit-06"),
Contains("CI * commit-05"),
Contains("CI commit-04"),
Contains("CI * commit-03"),
Contains("CI commit-02"),
Contains("CI commit-01"),
).
NavigateToLine(Contains("commit-06")).
Press(keys.Universal.RangeSelectDown).
Press(keys.Universal.RangeSelectDown).
Press(keys.Commits.MoveUpCommit).
Lines(
Contains("CI commit-06").IsSelected(),
/* EXPECTED:
Contains("CI * commit-05").IsSelected(),
ACTUAL: */
Contains("CI commit-05").IsSelected(),
Contains("CI commit-04").IsSelected(),
Contains("CI commit-07"),
Contains("CI * commit-03"),
Contains("CI commit-02"),
Contains("CI commit-01"),
)
},
})
+1
View File
@@ -392,6 +392,7 @@ var tests = []*components.IntegrationTest{
interactive_rebase.Move,
interactive_rebase.MoveAcrossBranchBoundaryOutsideRebase,
interactive_rebase.MoveInRebase,
interactive_rebase.MoveRangeSpanningBranchBoundaryOutsideRebase,
interactive_rebase.MoveTodoDownWithRapidKeypresses,
interactive_rebase.MoveUpdateRefTodo,
interactive_rebase.MoveWithCustomCommentChar,