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
|
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CheckoutFileFromCommit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Checkout a file from a commit",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file.txt", "one\n")
shell.Commit("one")
shell.CreateFileAndAdd("file.txt", "two\n")
shell.Commit("two")
shell.CreateFileAndAdd("file.txt", "three\n")
shell.Commit("three")
shell.CreateFileAndAdd("file.txt", "four\n")
shell.Commit("four")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
).
NavigateToLine(Contains("three")).
Tap(func() {
t.Views().Main().ContainsLines(
Contains("-two"),
Contains("+three"),
)
}).
PressEnter()
t.Views().CommitFiles().
IsFocused().
Lines(
Equals("M file.txt"),
).
Press(keys.CommitFiles.CheckoutCommitFile)
t.Views().Files().
Lines(
Equals("M file.txt"),
)
t.FileSystem().FileContent("file.txt", Equals("three\n"))
},
})
|