mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-06 13:00:59 -04:00
Add tests showing that the bisect menu offers marks once a bisect is done
Once git has nothing left to test, the bisect menu still offers marking or skipping the current commit, although the user has marked it already. This also happens if git stopped because the merge base of the good and the bad commit is bad. If git found the first bad commit without checking out anything to test, the menu acts on the selected commit, as if git didn't know both a good and a bad commit yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ba05949879
commit
5284818424
@@ -0,0 +1,44 @@
|
||||
package bisect
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var OfferResetWhenMergeBaseIsBad = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Offer to reset instead of showing the bisect menu when git stopped because the merge base is bad",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.
|
||||
CreateNCommits(2).
|
||||
NewBranch("fixed").
|
||||
CreateNCommitsStartingAt(1, 3).
|
||||
Checkout("master").
|
||||
CreateNCommitsStartingAt(2, 4).
|
||||
// Git checks out the merge base commit-02 to test first. If it is
|
||||
// bad, git can't find the first bad commit, and stops.
|
||||
StartBisect("master", "fixed").
|
||||
RunCommandExpectError([]string{"git", "bisect", "bad"})
|
||||
},
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
cfg.GetUserConfig().Git.Log.ShowGraph = "never"
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("CI commit-05"),
|
||||
Contains("CI commit-04"),
|
||||
Contains("CI commit-02").Contains("<-- bad").IsSelected(),
|
||||
Contains("CI commit-01"),
|
||||
).
|
||||
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()
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,41 @@
|
||||
package bisect
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var ShowResultAgain = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Show the result of a finished bisect again instead of the bisect menu",
|
||||
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().
|
||||
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().
|
||||
Focus().
|
||||
Press(keys.Commits.ViewBisectOptions)
|
||||
|
||||
t.ExpectToast(Equals("Disabled: Bisecting is in progress; use the commits panel"))
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,44 @@
|
||||
package bisect
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var ShowResultWhenFoundRightAway = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Show the result instead of the bisect menu when git found the first bad commit without testing any",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.
|
||||
CreateNCommits(3).
|
||||
// The good commit is the parent of the bad one, so git doesn't
|
||||
// check out anything to test
|
||||
StartBisect("HEAD", "HEAD~1")
|
||||
},
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
cfg.GetUserConfig().Git.Log.ShowGraph = "never"
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("CI commit-03").Contains("<-- bad").IsSelected(),
|
||||
Contains("CI commit-02").Contains("<-- good"),
|
||||
Contains("CI commit-01"),
|
||||
).
|
||||
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().
|
||||
Focus().
|
||||
Press(keys.Commits.ViewBisectOptions)
|
||||
|
||||
t.ExpectToast(Equals("Disabled: Bisecting is in progress; use the commits panel"))
|
||||
},
|
||||
})
|
||||
@@ -39,10 +39,13 @@ var tests = []*components.IntegrationTest{
|
||||
bisect.CheckOutBranchBeforeBisecting,
|
||||
bisect.ChooseTerms,
|
||||
bisect.FromOtherBranch,
|
||||
bisect.OfferResetWhenMergeBaseIsBad,
|
||||
bisect.SelectCurrentCommit,
|
||||
bisect.SelectCurrentCommitInLongRange,
|
||||
bisect.SelectFirstBadCommit,
|
||||
bisect.SelectFirstBadCommitOnStartup,
|
||||
bisect.ShowResultAgain,
|
||||
bisect.ShowResultWhenFoundRightAway,
|
||||
bisect.Skip,
|
||||
bisect.StartFromBranches,
|
||||
bisect.StartFromSubCommitsAndReflog,
|
||||
|
||||
Reference in New Issue
Block a user