-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
rebase.go
122 lines (119 loc) · 4.01 KB
/
rebase.go
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Begins an interactive rebase, then fixups, drops, and squashes some commits",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("initial commit")
shell.EmptyCommit("first commit to edit")
shell.EmptyCommit("commit to squash")
shell.EmptyCommit("second commit to edit")
shell.EmptyCommit("commit to drop")
shell.CreateFileAndAdd("fixup-commit-file", "fixup-commit-file")
shell.Commit("commit to fixup")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("commit to fixup"),
Contains("commit to drop"),
Contains("second commit to edit"),
Contains("commit to squash"),
Contains("first commit to edit"),
Contains("initial commit"),
).
NavigateToLine(Contains("first commit to edit")).
Press(keys.Universal.Edit).
Lines(
MatchesRegexp("pick.*commit to fixup"),
MatchesRegexp("pick.*commit to drop"),
MatchesRegexp("pick.*second commit to edit"),
MatchesRegexp("pick.*commit to squash"),
MatchesRegexp("YOU ARE HERE.*first commit to edit").IsSelected(),
Contains("initial commit"),
).
SelectPreviousItem().
Press(keys.Commits.SquashDown).
Lines(
MatchesRegexp("pick.*commit to fixup"),
MatchesRegexp("pick.*commit to drop"),
MatchesRegexp("pick.*second commit to edit"),
MatchesRegexp("squash.*commit to squash").IsSelected(),
MatchesRegexp("YOU ARE HERE.*first commit to edit"),
Contains("initial commit"),
).
SelectPreviousItem().
Press(keys.Universal.Edit).
Lines(
MatchesRegexp("pick.*commit to fixup"),
MatchesRegexp("pick.*commit to drop"),
MatchesRegexp("edit.*second commit to edit").IsSelected(),
MatchesRegexp("squash.*commit to squash"),
MatchesRegexp("YOU ARE HERE.*first commit to edit"),
Contains("initial commit"),
).
SelectPreviousItem().
Press(keys.Universal.Remove).
Lines(
MatchesRegexp("pick.*commit to fixup"),
MatchesRegexp("drop.*commit to drop").IsSelected(),
MatchesRegexp("edit.*second commit to edit"),
MatchesRegexp("squash.*commit to squash"),
MatchesRegexp("YOU ARE HERE.*first commit to edit"),
Contains("initial commit"),
).
SelectPreviousItem().
Press(keys.Commits.MarkCommitAsFixup).
Lines(
MatchesRegexp("fixup.*commit to fixup").IsSelected(),
MatchesRegexp("drop.*commit to drop"),
MatchesRegexp("edit.*second commit to edit"),
MatchesRegexp("squash.*commit to squash"),
MatchesRegexp("YOU ARE HERE.*first commit to edit"),
Contains("initial commit"),
).
Tap(func() {
t.Common().ContinueRebase()
}).
Lines(
MatchesRegexp("fixup.*commit to fixup").IsSelected(),
MatchesRegexp("drop.*commit to drop"),
MatchesRegexp("YOU ARE HERE.*second commit to edit"),
MatchesRegexp("first commit to edit"),
Contains("initial commit"),
).
Tap(func() {
t.Common().ContinueRebase()
}).
Lines(
Contains("second commit to edit").IsSelected(),
Contains("first commit to edit"),
Contains("initial commit"),
).
Tap(func() {
// commit 4 was squashed into 6 so we assert that their messages have been concatenated
t.Views().Main().Content(
Contains("second commit to edit").
// file from fixup commit is present
Contains("fixup-commit-file").
// but message is not (because it's a fixup, not a squash)
DoesNotContain("commit to fixup"),
)
}).
SelectNextItem().
Tap(func() {
// commit 4 was squashed into 6 so we assert that their messages have been concatenated
t.Views().Main().Content(
Contains("first commit to edit").
// message from squashed commit has been concatenated with message other commit
Contains("commit to squash"),
)
})
},
})