File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ package commit
2
+
3
+ import (
4
+ "github.com/jesseduffield/lazygit/pkg/config"
5
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
6
+ )
7
+
8
+ var CheckoutFileFromCommit = NewIntegrationTest (NewIntegrationTestArgs {
9
+ Description : "Checkout a file from a commit" ,
10
+ ExtraCmdArgs : []string {},
11
+ Skip : false ,
12
+ SetupConfig : func (config * config.AppConfig ) {},
13
+ SetupRepo : func (shell * Shell ) {
14
+ shell .CreateFileAndAdd ("file.txt" , "one\n " )
15
+ shell .Commit ("one" )
16
+ shell .CreateFileAndAdd ("file.txt" , "two\n " )
17
+ shell .Commit ("two" )
18
+ shell .CreateFileAndAdd ("file.txt" , "three\n " )
19
+ shell .Commit ("three" )
20
+ shell .CreateFileAndAdd ("file.txt" , "four\n " )
21
+ shell .Commit ("four" )
22
+ },
23
+ Run : func (t * TestDriver , keys config.KeybindingConfig ) {
24
+ t .Views ().Commits ().
25
+ Focus ().
26
+ Lines (
27
+ Contains ("four" ).IsSelected (),
28
+ Contains ("three" ),
29
+ Contains ("two" ),
30
+ Contains ("one" ),
31
+ ).
32
+ NavigateToLine (Contains ("three" )).
33
+ Tap (func () {
34
+ t .Views ().Main ().ContainsLines (
35
+ Contains ("-two" ),
36
+ Contains ("+three" ),
37
+ )
38
+ }).
39
+ PressEnter ()
40
+
41
+ t .Views ().CommitFiles ().
42
+ IsFocused ().
43
+ Lines (
44
+ Equals ("M file.txt" ),
45
+ ).
46
+ Press (keys .CommitFiles .CheckoutCommitFile )
47
+
48
+ t .Views ().Files ().
49
+ Lines (
50
+ Equals ("M file.txt" ),
51
+ )
52
+
53
+ t .FileSystem ().FileContent ("file.txt" , Equals ("three\n " ))
54
+ },
55
+ })
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ var tests = []*components.IntegrationTest{
89
89
commit .AmendWhenThereAreConflictsAndContinue ,
90
90
commit .AutoWrapMessage ,
91
91
commit .Checkout ,
92
+ commit .CheckoutFileFromCommit ,
92
93
commit .Commit ,
93
94
commit .CommitMultiline ,
94
95
commit .CommitSkipHooks ,
You can’t perform that action at this time.
0 commit comments