From e080c08b90bebf1c0639354b084938be20279a1e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 07:53:54 +0100 Subject: [PATCH] Add tests showing that a finished bisect doesn't select the first bad commit When the user marks the last commit to test as good, git reports the commit that is marked bad as the first bad commit. The commits view keeps the commit that the user just marked selected, though, so the user has to look for the result. The same happens when lazygit starts after a bisect has finished. Co-Authored-By: Claude Opus 5.5 --- .../tests/bisect/select_first_bad_commit.go | 42 +++++++++++++++++++ .../select_first_bad_commit_on_startup.go | 31 ++++++++++++++ pkg/integration/tests/test_list.go | 2 + 3 files changed, 75 insertions(+) create mode 100644 pkg/integration/tests/bisect/select_first_bad_commit.go create mode 100644 pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go diff --git a/pkg/integration/tests/bisect/select_first_bad_commit.go b/pkg/integration/tests/bisect/select_first_bad_commit.go new file mode 100644 index 000000000..1e76cba29 --- /dev/null +++ b/pkg/integration/tests/bisect/select_first_bad_commit.go @@ -0,0 +1,42 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectFirstBadCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select the first bad commit when marking the last commit to test finishes the bisect", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + StartBisect("HEAD~2", "HEAD~5") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + TopLines( + Contains("CI commit-10"), + Contains("CI commit-09"), + Contains("CI commit-08").Contains("<-- bad"), + Contains("CI commit-07").Contains("<-- current").IsSelected(), + Contains("CI commit-06"), + Contains("CI commit-05").Contains("<-- good"), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm() + + t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() + }). + /* EXPECTED: + SelectedLine(Contains("CI commit-08").Contains("<-- bad")) + ACTUAL: */ + SelectedLine(Contains("CI commit-07")) + }, +}) diff --git a/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go b/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go new file mode 100644 index 000000000..00d6f4919 --- /dev/null +++ b/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go @@ -0,0 +1,31 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectFirstBadCommitOnStartup = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select the first bad commit when starting with a finished bisect", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + StartBisect("HEAD~2", "HEAD~5"). + // Mark commit-07, the commit that git checked out to test. This + // finishes the bisect, because commit-08 is bad. + RunCommand([]string{"git", "bisect", "good"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + /* EXPECTED: + SelectedLine(Contains("CI commit-08").Contains("<-- bad")) + ACTUAL: */ + SelectedLine(Contains("CI commit-07")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 987713b3c..b0aad9c53 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -41,6 +41,8 @@ var tests = []*components.IntegrationTest{ bisect.FromOtherBranch, bisect.SelectCurrentCommit, bisect.SelectCurrentCommitInLongRange, + bisect.SelectFirstBadCommit, + bisect.SelectFirstBadCommitOnStartup, bisect.Skip, bisect.StartFromBranches, bisect.StartFromSubCommitsAndReflog,