From 9383172a6c2ae4d8e5a9a41286a5d726cea61d65 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 15:44:43 +0100 Subject: [PATCH] Add a test demonstrating that the conflicts popup disappears If moving a custom patch into a new commit before the original one results in a conflict, lazygit shows the "Conflicts!" popup, but then immediately focuses the commits view. This closes the popup, and the user is left in a rebase that is stopped at a conflict without being told about it. The test uses a pre-commit hook that changes a file of the new commit; this makes picking the original commit conflict. Co-Authored-By: Claude Opus 5.5 --- ...atch_to_new_commit_before_with_conflict.go | 69 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 70 insertions(+) create mode 100644 pkg/integration/tests/main_view/move_patch_to_new_commit_before_with_conflict.go diff --git a/pkg/integration/tests/main_view/move_patch_to_new_commit_before_with_conflict.go b/pkg/integration/tests/main_view/move_patch_to_new_commit_before_with_conflict.go new file mode 100644 index 000000000..512cb1436 --- /dev/null +++ b/pkg/integration/tests/main_view/move_patch_to_new_commit_before_with_conflict.go @@ -0,0 +1,69 @@ +package main_view + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var MovePatchToNewCommitBeforeWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Move a patch into a new commit before the original commit, where a commit hook changes the new commit so that replaying the original commit conflicts", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file1", "1st line\n") + shell.Commit("first commit") + + shell.UpdateFileAndAdd("file1", "1st line\n2nd line\n") + shell.CreateFileAndAdd("file2", "file2 content\n") + shell.Commit("commit to move from") + + shell.CreateFile(".git/hooks/pre-commit", "#!/bin/sh\necho 'hook line' >> file1\ngit add file1\n") + shell.MakeExecutable(".git/hooks/pre-commit") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("commit to move from").IsSelected(), + Contains("first commit"), + ). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Equals("▼ /").IsSelected(), + Contains("file1"), + Contains("file2"), + ). + NavigateToLine(Contains("file2")). + PressPrimaryAction() + + t.Views().Information().Content(Contains("Building patch")) + t.Common().SelectPatchOption(Contains("Move patch into new commit before the original commit")) + + t.ExpectPopup().CommitMessagePanel(). + InitialText(Equals("")). + Type("new commit").Confirm() + + /* EXPECTED: + t.Common().AcknowledgeConflicts() + + t.Views().Files(). + IsFocused(). + Lines( + Contains("UU").Contains("file1"), + ) + ACTUAL: */ + t.Views().Commits(). + IsFocused(). + Lines( + Contains("─── Pending rebase todos"), + Contains("pick").Contains("<-- CONFLICT --- commit to move from"), + Contains("─── Commits"), + Contains("new commit"), + Contains("first commit"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 6e902bacb..13282ef5d 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -471,6 +471,7 @@ var tests = []*components.IntegrationTest{ main_view.MovePatchToLaterCommit, main_view.MovePatchToNewCommit, main_view.MovePatchToNewCommitBefore, + main_view.MovePatchToNewCommitBeforeWithConflict, main_view.MovePatchToNewCommitInStackedBranch, main_view.NavigateByHunkAndFile, main_view.NoDiffStatLinksUnderAnExternalDiff,