diff --git a/pkg/integration/tests/interactive_rebase/edit_last_commit_of_stacked_branch.go b/pkg/integration/tests/interactive_rebase/edit_last_commit_of_stacked_branch.go new file mode 100644 index 000000000..92571173e --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/edit_last_commit_of_stacked_branch.go @@ -0,0 +1,79 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var EditLastCommitOfStackedBranch = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Edit and amend the last commit of a branch in a stack of branches, and ensure that it doesn't break the stack", + ExtraCmdArgs: []string{}, + Skip: false, + GitVersion: AtLeast("2.38.0"), + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().Git.MainBranches = []string{"master"} + config.GetAppState().GitLogShowGraph = "never" + }, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(1). + NewBranch("branch1"). + CreateNCommitsStartingAt(2, 2). + NewBranch("branch2"). + CreateNCommitsStartingAt(2, 4) + + shell.SetConfig("rebase.updateRefs", "true") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("CI commit 05").IsSelected(), + Contains("CI commit 04"), + Contains("CI * commit 03"), + Contains("CI commit 02"), + Contains("CI commit 01"), + ). + NavigateToLine(Contains("commit 03")). + Press(keys.Universal.Edit). + Lines( + Contains("pick").Contains("CI commit 05"), + Contains("pick").Contains("CI commit 04"), + /* EXPECTED: + Contains("update-ref").Contains("branch1"), + */ + Contains("<-- YOU ARE HERE --- * commit 03").IsSelected(), + Contains("CI commit 02"), + Contains("CI commit 01"), + ) + + t.Shell().CreateFile("fixup-file", "fixup content") + t.Views().Files(). + Focus(). + Press(keys.Files.RefreshFiles). + Lines( + Contains("??").Contains("fixup-file").IsSelected(), + ). + PressPrimaryAction(). + Press(keys.Files.AmendLastCommit) + t.ExpectPopup().Confirmation(). + Title(Equals("Amend last commit")). + Content(Contains("Are you sure you want to amend last commit?")). + Confirm() + + t.Common().ContinueRebase() + + t.Views().Commits(). + Focus(). + Lines( + Contains("CI commit 05"), + Contains("CI commit 04"), + /* EXPECTED: + Contains("CI * commit 03"), + ACTUAL: */ + 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 40435b916..bbccc0294 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -211,6 +211,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.DropTodoCommitWithUpdateRef, interactive_rebase.DropWithCustomCommentChar, interactive_rebase.EditFirstCommit, + interactive_rebase.EditLastCommitOfStackedBranch, interactive_rebase.EditNonTodoCommitDuringRebase, interactive_rebase.EditRangeSelectOutsideRebase, interactive_rebase.EditTheConflCommit,