1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-03 15:02:52 +02:00

71 lines
1.9 KiB
Go
Raw Normal View History

2022-08-22 19:34:02 +10: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() {
input.Press(keys.Commits.ViewBisectOptions)
2022-12-27 11:34:41 +11:00
input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as bad`)).Confirm()
2022-08-22 19:34:02 +10:00
}
markCommitAsGood := func() {
input.Press(keys.Commits.ViewBisectOptions)
2022-12-27 11:34:41 +11:00
input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
2022-08-22 19:34:02 +10:00
}
assert.AtLeastOneCommit()
2022-12-26 16:49:54 +11:00
input.SwitchToCommitsView()
2022-08-22 19:34:02 +10:00
2022-12-27 15:07:11 +11:00
assert.Views().Current().SelectedLine(Contains("commit 10"))
2022-08-22 19:34:02 +10:00
input.NavigateToListItem(Contains("commit 09"))
2022-08-22 19:34:02 +10:00
markCommitAsBad()
2022-12-27 15:07:11 +11:00
assert.Views().ByName("information").Content(Contains("bisecting"))
2022-08-22 19:34:02 +10:00
2022-12-27 15:07:11 +11:00
assert.Views().Current().Name("commits").SelectedLine(Contains("<-- bad"))
2022-08-22 19:34:02 +10:00
input.NavigateToListItem(Contains("commit 02"))
2022-08-22 19:34:02 +10:00
markCommitAsGood()
// lazygit will land us in the commit between our good and bad commits.
2022-12-27 15:07:11 +11:00
assert.Views().Current().
2022-12-26 11:12:56 +11:00
Name("commits").
2022-12-26 17:15:33 +11:00
SelectedLine(Contains("commit 05").Contains("<-- current"))
2022-08-22 19:34:02 +10:00
markCommitAsBad()
2022-12-27 15:07:11 +11:00
assert.Views().Current().
2022-12-26 11:12:56 +11:00
Name("commits").
2022-12-26 17:15:33 +11:00
SelectedLine(Contains("commit 04").Contains("<-- current"))
2022-08-22 19:34:02 +10:00
markCommitAsGood()
// commit 5 is the culprit because we marked 4 as good and 5 as bad.
2022-12-27 11:34:41 +11:00
input.Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit 05.*Do you want to reset")).Confirm()
2022-08-22 19:34:02 +10:00
2022-12-27 15:07:11 +11:00
assert.Views().Current().Name("commits").Content(Contains("commit 04"))
assert.Views().ByName("information").Content(DoesNotContain("bisecting"))
2022-08-22 19:34:02 +10:00
},
})