-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
mid_rebase_range_select.go
184 lines (182 loc) · 6.43 KB
/
mid_rebase_range_select.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var MidRebaseRangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Do various things with range selection in the commits view when mid-rebase",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(10)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
TopLines(
Contains("commit 10").IsSelected(),
).
NavigateToLine(Contains("commit 05")).
// Start a rebase
Press(keys.Universal.Edit).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("pick").Contains("commit 07"),
Contains("pick").Contains("commit 06"),
Contains("<-- YOU ARE HERE --- commit 05").IsSelected(),
Contains("commit 04"),
).
SelectPreviousItem().
// perform various actions on a range of commits
Press(keys.Universal.RangeSelectUp).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("pick").Contains("commit 07").IsSelected(),
Contains("pick").Contains("commit 06").IsSelected(),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Press(keys.Commits.MarkCommitAsFixup).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("fixup").Contains("commit 07").IsSelected(),
Contains("fixup").Contains("commit 06").IsSelected(),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Press(keys.Commits.PickCommit).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("pick").Contains("commit 07").IsSelected(),
Contains("pick").Contains("commit 06").IsSelected(),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Press(keys.Universal.Edit).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("edit").Contains("commit 07").IsSelected(),
Contains("edit").Contains("commit 06").IsSelected(),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Press(keys.Commits.SquashDown).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("squash").Contains("commit 07").IsSelected(),
Contains("squash").Contains("commit 06").IsSelected(),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Press(keys.Commits.MoveDownCommit).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("squash").Contains("commit 07").IsSelected(),
Contains("squash").Contains("commit 06").IsSelected(),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Tap(func() {
t.ExpectToast(Contains("Disabled: Cannot move any further"))
}).
Press(keys.Commits.MoveUpCommit).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("squash").Contains("commit 07").IsSelected(),
Contains("squash").Contains("commit 06").IsSelected(),
Contains("pick").Contains("commit 08"),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Press(keys.Commits.MoveUpCommit).
TopLines(
Contains("pick").Contains("commit 10"),
Contains("squash").Contains("commit 07").IsSelected(),
Contains("squash").Contains("commit 06").IsSelected(),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Press(keys.Commits.MoveUpCommit).
TopLines(
Contains("squash").Contains("commit 07").IsSelected(),
Contains("squash").Contains("commit 06").IsSelected(),
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
Press(keys.Commits.MoveUpCommit).
Tap(func() {
t.ExpectToast(Contains("Disabled: Cannot move any further"))
}).
TopLines(
Contains("squash").Contains("commit 07").IsSelected(),
Contains("squash").Contains("commit 06").IsSelected(),
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08"),
Contains("<-- YOU ARE HERE --- commit 05"),
Contains("commit 04"),
).
// Verify we can't perform an action on a range that includes both
// TODO and non-TODO commits
NavigateToLine(Contains("commit 08")).
Press(keys.Universal.RangeSelectDown).
TopLines(
Contains("squash").Contains("commit 07"),
Contains("squash").Contains("commit 06"),
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08").IsSelected(),
Contains("<-- YOU ARE HERE --- commit 05").IsSelected(),
Contains("commit 04"),
).
Press(keys.Commits.MarkCommitAsFixup).
Tap(func() {
t.ExpectToast(Contains("Disabled: When rebasing, this action only works on a selection of TODO commits."))
}).
TopLines(
Contains("squash").Contains("commit 07"),
Contains("squash").Contains("commit 06"),
Contains("pick").Contains("commit 10"),
Contains("pick").Contains("commit 09"),
Contains("pick").Contains("commit 08").IsSelected(),
Contains("<-- YOU ARE HERE --- commit 05").IsSelected(),
Contains("commit 04"),
).
// continue the rebase
Tap(func() {
t.Common().ContinueRebase()
}).
TopLines(
Contains("commit 10"),
Contains("commit 09"),
Contains("commit 08"),
Contains("commit 05"),
// selected indexes are retained, though we may want to clear it
// in future (not sure what the best behaviour is right now)
Contains("commit 04").IsSelected(),
Contains("commit 03").IsSelected(),
)
},
})