1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Checkout a commit as a detached head, or checkout an existing branch at a commit",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical"
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.NewBranch("branch1")
shell.NewBranch("branch2")
shell.EmptyCommit("three")
shell.EmptyCommit("four")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
).
PressPrimaryAction()
t.ExpectPopup().Menu().
Title(Contains("Checkout branch or commit")).
Lines(
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(),
Contains("Checkout branch"),
Contains("Cancel"),
).
Select(Contains("Checkout branch")).
Tooltip(Contains("Disabled: No branches found at selected commit.")).
Select(MatchesRegexp("Checkout commit [a-f0-9]+ as detached head")).
Confirm()
t.Views().Branches().
IsFocused().
Lines(
Contains("* (HEAD detached at").IsSelected(),
Contains("branch1"),
Contains("branch2"),
Contains("master"),
)
t.Views().Commits().
Focus().
NavigateToLine(Contains("two")).
PressPrimaryAction()
t.ExpectPopup().Menu().
Title(Contains("Checkout branch or commit")).
Lines(
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(),
Contains("Checkout branch 'branch1'"),
Contains("Checkout branch 'master'"),
Contains("Cancel"),
).
Select(Contains("Checkout branch 'master'")).
Confirm()
t.Views().Branches().
IsFocused().
Lines(
Contains("master").IsSelected(),
Contains("branch1"),
Contains("branch2"),
)
},
})
|