diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index dd0d4dd94..36d43692f 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -81,12 +81,33 @@ func (self *BisectController) openMenu(ref models.Ref) error { if !info.Started() { return self.openStartBisectMenu(info, ref) } - if info.GetCurrentHash() == "" { + if !info.Bisecting() { return self.openMenuBeforeBisecting(info, ref) } + if !info.HasCommitToTest() { + return self.showBisectResult() + } return self.openMidBisectMenu(info, ref) } +// Git has nothing left for the user to test, so show the result, and offer to +// reset the bisect. +func (self *BisectController) showBisectResult() error { + done, candidateHashes, err := self.c.Git().Bisect.IsDone() + if err != nil { + return err + } + + if !done { + // Git stopped without finding the first bad commit, for example + // because the merge base of the good and the bad commit is bad. Git + // said why when it stopped, so all that's left to do is to reset. + return self.c.Helpers().Bisect.Reset() + } + + return self.showBisectCompleteMessage(candidateHashes) +} + // The menu for when a bisect has started, but git doesn't know both a good and // a bad commit yet. Its entries act on the selected item. func (self *BisectController) openMenuBeforeBisecting(info *git_commands.BisectInfo, ref models.Ref) error { diff --git a/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go b/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go index 2c8b9302a..a9758e6e2 100644 --- a/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go +++ b/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go @@ -35,10 +35,7 @@ var OfferResetWhenMergeBaseIsBad = NewIntegrationTest(NewIntegrationTestArgs{ ). Press(keys.Commits.ViewBisectOptions). Tap(func() { - /* EXPECTED: t.ExpectPopup().Confirmation().Title(Equals("Reset 'git bisect'")).Content(Equals("Are you sure you want to reset 'git bisect'?")).Cancel() - ACTUAL: */ - t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(Contains("Mark current commit")).Cancel() }) }, }) diff --git a/pkg/integration/tests/bisect/show_result_again.go b/pkg/integration/tests/bisect/show_result_again.go index ac2406732..073cf1456 100644 --- a/pkg/integration/tests/bisect/show_result_again.go +++ b/pkg/integration/tests/bisect/show_result_again.go @@ -26,10 +26,7 @@ var ShowResultAgain = NewIntegrationTest(NewIntegrationTestArgs{ SelectedLine(Contains("CI commit-08").Contains("<-- bad")). Press(keys.Commits.ViewBisectOptions). Tap(func() { - /* EXPECTED: t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() - ACTUAL: */ - t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(Contains("Mark current commit")).Cancel() }) t.Views().Branches(). diff --git a/pkg/integration/tests/bisect/show_result_when_found_right_away.go b/pkg/integration/tests/bisect/show_result_when_found_right_away.go index 98f4fd7a8..ea74ebe04 100644 --- a/pkg/integration/tests/bisect/show_result_when_found_right_away.go +++ b/pkg/integration/tests/bisect/show_result_when_found_right_away.go @@ -29,10 +29,7 @@ var ShowResultWhenFoundRightAway = NewIntegrationTest(NewIntegrationTestArgs{ ). Press(keys.Commits.ViewBisectOptions). Tap(func() { - /* EXPECTED: t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-03.*Do you want to reset")).Cancel() - ACTUAL: */ - t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(MatchesRegexp(`b Mark commit [0-9a-f]+ as bad`)).Cancel() }) t.Views().Branches().