diff options
Diffstat (limited to 'pkg/integration/tests/interactive_rebase')
4 files changed, 155 insertions, 1 deletions
diff --git a/pkg/integration/tests/interactive_rebase/advanced_interactive_rebase.go b/pkg/integration/tests/interactive_rebase/advanced_interactive_rebase.go index 43ac8eb7f..771b2e164 100644 --- a/pkg/integration/tests/interactive_rebase/advanced_interactive_rebase.go +++ b/pkg/integration/tests/interactive_rebase/advanced_interactive_rebase.go @@ -39,7 +39,7 @@ var AdvancedInteractiveRebase = NewIntegrationTest(NewIntegrationTestArgs{ Press(keys.Branches.RebaseBranch) t.ExpectPopup().Menu(). - Title(Equals(fmt.Sprintf("Rebase '%s' onto '%s'", TOP_BRANCH, BASE_BRANCH))). + Title(Equals(fmt.Sprintf("Rebase '%s'", TOP_BRANCH))). Select(Contains("Interactive rebase")). Confirm() t.Views().Commits(). diff --git a/pkg/integration/tests/interactive_rebase/drop_commit_in_copied_branch_with_update_ref.go b/pkg/integration/tests/interactive_rebase/drop_commit_in_copied_branch_with_update_ref.go new file mode 100644 index 000000000..8ea13c6e2 --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/drop_commit_in_copied_branch_with_update_ref.go @@ -0,0 +1,56 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var DropCommitInCopiedBranchWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Drops a commit in a branch that is a copy of another branch, and verify that the other branch is left alone", + ExtraCmdArgs: []string{}, + Skip: false, + GitVersion: AtLeast("2.38.0"), + SetupConfig: func(config *config.AppConfig) { + config.AppState.GitLogShowGraph = "never" + }, + SetupRepo: func(shell *Shell) { + shell. + NewBranch("branch1"). + CreateNCommits(3). + NewBranch("branch2") + + shell.SetConfig("rebase.updateRefs", "true") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("CI * commit 03").IsSelected(), + Contains("CI commit 02"), + Contains("CI commit 01"), + ). + NavigateToLine(Contains("commit 02")). + Press(keys.Universal.Remove). + Tap(func() { + t.ExpectPopup().Confirmation(). + Title(Equals("Drop commit")). + Content(Equals("Are you sure you want to drop the selected commit(s)?")). + Confirm() + }). + Lines( + Contains("CI commit 03"), // no start on this commit because branch1 is no longer pointing to it + Contains("CI commit 01"), + ) + + t.Views().Branches(). + Focus(). + NavigateToLine(Contains("branch1")). + PressPrimaryAction() + + t.Views().Commits().Lines( + Contains("CI commit 03"), + Contains("CI commit 02"), + Contains("CI commit 01"), + ) + }, +}) diff --git a/pkg/integration/tests/interactive_rebase/interactive_rebase_of_copied_branch.go b/pkg/integration/tests/interactive_rebase/interactive_rebase_of_copied_branch.go new file mode 100644 index 000000000..4bb3b86c7 --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/interactive_rebase_of_copied_branch.go @@ -0,0 +1,41 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var InteractiveRebaseOfCopiedBranch = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Check that interactively rebasing a branch that is a copy of another branch doesn't affect the original branch", + ExtraCmdArgs: []string{}, + Skip: false, + GitVersion: AtLeast("2.38.0"), + SetupConfig: func(config *config.AppConfig) { + config.AppState.GitLogShowGraph = "never" + }, + SetupRepo: func(shell *Shell) { + shell. + NewBranch("branch1"). + CreateNCommits(3). + NewBranch("branch2") + + shell.SetConfig("rebase.updateRefs", "true") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("CI * commit 03"), + Contains("CI commit 02"), + Contains("CI commit 01"), + ). + NavigateToLine(Contains("commit 01")). + Press(keys.Universal.Edit). + Lines( + // No update-ref todo for branch1 here, even though command-line git would have added it + Contains("pick").Contains("CI commit 03"), + Contains("pick").Contains("CI commit 02"), + Contains("CI <-- YOU ARE HERE --- commit 01"), + ) + }, +}) diff --git a/pkg/integration/tests/interactive_rebase/show_exec_todos.go b/pkg/integration/tests/interactive_rebase/show_exec_todos.go new file mode 100644 index 000000000..b66036d02 --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/show_exec_todos.go @@ -0,0 +1,57 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ShowExecTodos = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Show exec todos in the rebase todo list", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(cfg *config.AppConfig) { + cfg.UserConfig.CustomCommands = []config.CustomCommand{ + { + Key: "X", + Context: "commits", + Command: "git -c core.editor=: rebase -i -x false HEAD^^", + }, + } + }, + SetupRepo: func(shell *Shell) { + shell. + NewBranch("branch1"). + CreateNCommits(3) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Press("X"). + Tap(func() { + t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("Rebasing (2/4)Executing: false")).Confirm() + }). + Lines( + Contains("exec").Contains("false"), + Contains("pick").Contains("CI commit 03"), + Contains("CI ◯ <-- YOU ARE HERE --- commit 02"), + Contains("CI ◯ commit 01"), + ). + Tap(func() { + t.Common().ContinueRebase() + t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("exit status 1")).Confirm() + }). + Lines( + Contains("CI ◯ <-- YOU ARE HERE --- commit 03"), + Contains("CI ◯ commit 02"), + Contains("CI ◯ commit 01"), + ). + Tap(func() { + t.Common().ContinueRebase() + }). + Lines( + Contains("CI ◯ commit 03"), + Contains("CI ◯ commit 02"), + Contains("CI ◯ commit 01"), + ) + }, +}) |