From 50b2aa5843c2b202cfa787db6e2a543a0b4bfb70 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 10 May 2025 18:15:26 +0200 Subject: [PATCH] Add test for rewording a merge commit This currently fails with an error. --- .../interactive_rebase/reword_merge_commit.go | 56 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 57 insertions(+) create mode 100644 pkg/integration/tests/interactive_rebase/reword_merge_commit.go diff --git a/pkg/integration/tests/interactive_rebase/reword_merge_commit.go b/pkg/integration/tests/interactive_rebase/reword_merge_commit.go new file mode 100644 index 000000000..e4c1ee210 --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/reword_merge_commit.go @@ -0,0 +1,56 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var RewordMergeCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Rewords a merge commit which is not the current head commit", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + EmptyCommit("base"). + NewBranch("first-branch"). + CreateFileAndAdd("file1.txt", "content"). + Commit("one"). + Checkout("master"). + Merge("first-branch"). + NewBranch("second-branch"). + EmptyCommit("two") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("CI ◯ two").IsSelected(), + Contains("CI ⏣─╮ Merge branch 'first-branch'"), + Contains("CI │ ◯ one"), + Contains("CI ◯─╯ base"), + ). + SelectNextItem(). + Press(keys.Commits.RenameCommit). + Tap(func() { + t.ExpectPopup().CommitMessagePanel(). + Title(Equals("Reword commit")). + InitialText(Equals("Merge branch 'first-branch'")). + Clear(). + Type("renamed merge"). + Confirm() + }). + /* EXPECTED: + Lines( + Contains("CI ◯ two"), + Contains("CI ⏣─╮ renamed merge").IsSelected(), + Contains("CI │ ◯ one"), + Contains("CI ◯ ╯ base"), + ) + ACTUAL: */ + Tap(func() { + t.ExpectPopup().Alert().Title(Equals("Error")). + Content(Contains("error: 'edit' does not accept merge commits")) + }) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 6093a387a..f5f2be22a 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -275,6 +275,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.RewordFirstCommit, interactive_rebase.RewordLastCommit, interactive_rebase.RewordLastCommitOfStackedBranch, + interactive_rebase.RewordMergeCommit, interactive_rebase.RewordYouAreHereCommit, interactive_rebase.RewordYouAreHereCommitWithEditor, interactive_rebase.ShowExecTodos,