From f8877eef26c272fbdc1ba317625142d16fa3d494 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 6 Nov 2026 10:01:17 +0100 Subject: [PATCH] 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 --- ...spanning_branch_boundary_outside_rebase.go | 58 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 59 insertions(+) create mode 100644 pkg/integration/tests/interactive_rebase/move_range_spanning_branch_boundary_outside_rebase.go diff --git a/pkg/integration/tests/interactive_rebase/move_range_spanning_branch_boundary_outside_rebase.go b/pkg/integration/tests/interactive_rebase/move_range_spanning_branch_boundary_outside_rebase.go new file mode 100644 index 000000000..3e5ba9f18 --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/move_range_spanning_branch_boundary_outside_rebase.go @@ -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"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 79d40de3e..36c7475b1 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -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,