From b41bb8f845f3c9abc95c50bf32fe7eff127ce400 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 16 Jan 2026 08:33:33 +0100 Subject: [PATCH] Add a test that documents the current behavior Currently we get an annoying error message, but we'd like the base commit to be selected, disregarding the fixup. --- ...p_disregard_fixups_for_same_base_commit.go | 46 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 47 insertions(+) create mode 100644 pkg/integration/tests/commit/find_base_commit_for_fixup_disregard_fixups_for_same_base_commit.go diff --git a/pkg/integration/tests/commit/find_base_commit_for_fixup_disregard_fixups_for_same_base_commit.go b/pkg/integration/tests/commit/find_base_commit_for_fixup_disregard_fixups_for_same_base_commit.go new file mode 100644 index 000000000..07f32126a --- /dev/null +++ b/pkg/integration/tests/commit/find_base_commit_for_fixup_disregard_fixups_for_same_base_commit.go @@ -0,0 +1,46 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var FindBaseCommitForFixupDisregardFixupsForSameBaseCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Finds the base commit to create a fixup for, disregarding fixup commits for the same base commit", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + EmptyCommit("1st commit"). + NewBranch("mybranch"). + CreateFileAndAdd("file1", "1\n2\n3\n"). + Commit("2nd commit"). + UpdateFileAndAdd("file1", "1\n2\n3a\n"). + Commit("fixup! 2nd commit"). + EmptyCommit("3rd commit"). + UpdateFileAndAdd("file1", "1a\n2\n3b\n") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Lines( + Contains("3rd commit").IsSelected(), + Contains("fixup! 2nd commit"), + Contains("2nd commit"), + Contains("1st commit"), + ) + + t.Views().Files(). + Focus(). + Press(keys.Files.FindBaseCommitForFixup) + + t.ExpectPopup().Alert(). + Title(Equals("Error")). + Content( + MatchesRegexp("Multiple base commits found.*\n\n" + + ".*fixup! 2nd commit\n" + + ".*2nd commit"), + ). + Confirm() + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 26d6d3030..faf35a601 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -130,6 +130,7 @@ var tests = []*components.IntegrationTest{ commit.DoNotShowBranchMarkerForHeadCommit, commit.FailHooksThenCommitNoHooks, commit.FindBaseCommitForFixup, + commit.FindBaseCommitForFixupDisregardFixupsForSameBaseCommit, commit.FindBaseCommitForFixupDisregardMainBranch, commit.FindBaseCommitForFixupOnlyAddedLines, commit.FindBaseCommitForFixupWarningForAddedLines,