2022-08-22 11:34:02 +02:00
|
|
|
package bisect
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
|
|
|
Description: "Start a git bisect to find a bad commit",
|
|
|
|
ExtraCmdArgs: "",
|
|
|
|
Skip: false,
|
|
|
|
SetupRepo: func(shell *Shell) {
|
|
|
|
shell.
|
|
|
|
CreateNCommits(10)
|
|
|
|
},
|
|
|
|
SetupConfig: func(cfg *config.AppConfig) {},
|
|
|
|
Run: func(
|
|
|
|
shell *Shell,
|
|
|
|
input *Input,
|
|
|
|
assert *Assert,
|
|
|
|
keys config.KeybindingConfig,
|
|
|
|
) {
|
|
|
|
markCommitAsBad := func() {
|
2022-12-24 08:48:57 +02:00
|
|
|
input.Press(keys.Commits.ViewBisectOptions)
|
|
|
|
input.Menu(Equals("Bisect"), MatchesRegexp(`mark .* as bad`))
|
2022-08-22 11:34:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
markCommitAsGood := func() {
|
2022-12-24 08:48:57 +02:00
|
|
|
input.Press(keys.Commits.ViewBisectOptions)
|
|
|
|
input.Menu(Equals("Bisect"), MatchesRegexp(`mark .* as good`))
|
2022-08-22 11:34:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
assert.AtLeastOneCommit()
|
|
|
|
|
|
|
|
input.SwitchToCommitsWindow()
|
|
|
|
|
2022-12-26 01:42:19 +02:00
|
|
|
assert.CurrentLine(Contains("commit 10"))
|
2022-08-22 11:34:02 +02:00
|
|
|
|
2022-12-24 08:48:57 +02:00
|
|
|
input.NavigateToListItem(Contains("commit 09"))
|
2022-08-22 11:34:02 +02:00
|
|
|
|
|
|
|
markCommitAsBad()
|
|
|
|
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.ViewContent("information", Contains("bisecting"))
|
2022-08-22 11:34:02 +02:00
|
|
|
|
|
|
|
assert.CurrentViewName("commits")
|
2022-12-26 01:42:19 +02:00
|
|
|
assert.CurrentLine(Contains("<-- bad"))
|
2022-08-22 11:34:02 +02:00
|
|
|
|
2022-12-24 08:48:57 +02:00
|
|
|
input.NavigateToListItem(Contains("commit 02"))
|
2022-08-22 11:34:02 +02:00
|
|
|
|
|
|
|
markCommitAsGood()
|
|
|
|
|
2022-12-24 08:48:57 +02:00
|
|
|
// lazygit will land us in the commit between our good and bad commits.
|
2022-08-22 11:34:02 +02:00
|
|
|
assert.CurrentViewName("commits")
|
2022-12-26 01:42:19 +02:00
|
|
|
assert.CurrentLine(Contains("commit 05"))
|
|
|
|
assert.CurrentLine(Contains("<-- current"))
|
2022-08-22 11:34:02 +02:00
|
|
|
|
|
|
|
markCommitAsBad()
|
|
|
|
|
|
|
|
assert.CurrentViewName("commits")
|
2022-12-26 01:42:19 +02:00
|
|
|
assert.CurrentLine(Contains("commit 04"))
|
|
|
|
assert.CurrentLine(Contains("<-- current"))
|
2022-08-22 11:34:02 +02:00
|
|
|
|
|
|
|
markCommitAsGood()
|
|
|
|
|
|
|
|
// commit 5 is the culprit because we marked 4 as good and 5 as bad.
|
2022-12-24 08:48:57 +02:00
|
|
|
input.Alert(Equals("Bisect complete"), MatchesRegexp("(?s)commit 05.*Do you want to reset"))
|
2022-08-22 11:34:02 +02:00
|
|
|
|
|
|
|
assert.CurrentViewName("commits")
|
2022-12-24 08:01:26 +02:00
|
|
|
assert.CurrentViewContent(Contains("commit 04"))
|
|
|
|
assert.ViewContent("information", NotContains("bisecting"))
|
2022-08-22 11:34:02 +02:00
|
|
|
},
|
|
|
|
})
|