summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-07-27 14:15:56 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-29 11:59:58 +0200
commitf30e09856cb14ee4b6ec4457588e960e4f52eb24 (patch)
treec69052f00084a85441109623066374187c64c0bc /pkg/integration
parent9b7f978e3e305908d4c8da21462e3b7974346d66 (diff)
Add bisect menu entry that lets you choose bisect terms
This can be useful if you want to find the commit that fixed a bug (you'd use "broken/fixed" instead of "good/bad" in this case), or if you want to find the commit that brought a big performance improvement (use "slow/fast"). It's pretty mind-bending to have to use "good/bad" in these cases, and swap their meanings in your head. Thankfully, lazygit already had support for using custom terms during the bisect (for the case that a bisect was started on the command-line, I suppose), so all that's needed is adding a way to specify them in lazygit.
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/bisect/choose_terms.go72
-rw-r--r--pkg/integration/tests/test_list.go1
2 files changed, 73 insertions, 0 deletions
diff --git a/pkg/integration/tests/bisect/choose_terms.go b/pkg/integration/tests/bisect/choose_terms.go
new file mode 100644
index 000000000..825c8f5e2
--- /dev/null
+++ b/pkg/integration/tests/bisect/choose_terms.go
@@ -0,0 +1,72 @@
+package bisect
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var ChooseTerms = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Start a git bisect by choosing 'broken/fixed' as bisect terms",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupRepo: func(shell *Shell) {
+ shell.
+ NewBranch("mybranch").
+ CreateNCommits(10)
+ },
+ SetupConfig: func(cfg *config.AppConfig) {},
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ markCommitAsFixed := func() {
+ t.Views().Commits().
+ Press(keys.Commits.ViewBisectOptions)
+
+ t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as fixed`)).Confirm()
+ }
+
+ markCommitAsBroken := func() {
+ t.Views().Commits().
+ Press(keys.Commits.ViewBisectOptions)
+
+ t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as broken`)).Confirm()
+ }
+
+ t.Views().Commits().
+ Focus().
+ SelectedLine(Contains("CI commit 10")).
+ Press(keys.Commits.ViewBisectOptions).
+ Tap(func() {
+ t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(Contains("Choose bisect terms")).Confirm()
+ t.ExpectPopup().Prompt().Title(Equals("Term for old/good commit:")).Type("broken").Confirm()
+ t.ExpectPopup().Prompt().Title(Equals("Term for new/bad commit:")).Type("fixed").Confirm()
+ }).
+ NavigateToLine(Contains("CI commit 09")).
+ Tap(markCommitAsFixed).
+ SelectedLine(Contains("<-- fixed")).
+ NavigateToLine(Contains("CI commit 02")).
+ Tap(markCommitAsBroken).
+ Lines(
+ Contains("CI commit 10").DoesNotContain("<--"),
+ Contains("CI commit 09").Contains("<-- fixed"),
+ Contains("CI commit 08").DoesNotContain("<--"),
+ Contains("CI commit 07").DoesNotContain("<--"),
+ Contains("CI commit 06").DoesNotContain("<--"),
+ Contains("CI commit 05").Contains("<-- current").IsSelected(),
+ Contains("CI commit 04").DoesNotContain("<--"),
+ Contains("CI commit 03").DoesNotContain("<--"),
+ Contains("CI commit 02").Contains("<-- broken"),
+ Contains("CI commit 01").DoesNotContain("<--"),
+ ).
+ Tap(markCommitAsFixed).
+ SelectedLine(Contains("CI commit 04").Contains("<-- current")).
+ Tap(func() {
+ markCommitAsBroken()
+
+ // commit 5 is the culprit because we marked 4 as broken and 5 as fixed.
+ t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
+ }).
+ IsFocused().
+ Content(Contains("CI commit 04"))
+
+ t.Views().Information().Content(DoesNotContain("Bisecting"))
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 61a182ffa..17f01995c 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -30,6 +30,7 @@ import (
var tests = []*components.IntegrationTest{
bisect.Basic,
+ bisect.ChooseTerms,
bisect.FromOtherBranch,
branch.CheckoutByName,
branch.CreateTag,