-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
pr-list.feature
260 lines (243 loc) · 7.77 KB
/
pr-list.feature
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
Feature: hub pr list
Background:
Given I am in "git://github.com/github/hub.git" git repo
And I am "defunkt" on github.com with OAuth token "OTOKEN"
Scenario: List pulls
Given the GitHub API server:
"""
get('/repos/github/hub/pulls') {
assert :per_page => "100",
:page => :no,
:sort => nil,
:direction => "desc"
response.headers["Link"] = %(<https://api.github.com/repositories/12345?per_page=100&page=2>; rel="next")
json [
{ :number => 999,
:title => "First",
:state => "open",
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-1", :label => "octocat:patch-1" },
:user => { :login => "octocat" },
},
{ :number => 102,
:title => "Second",
:state => "open",
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-2", :label => "octocat:patch-2" },
:user => { :login => "octocat" },
},
{ :number => 13,
:title => "Third",
:state => "open",
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-3", :label => "octocat:patch-3" },
:user => { :login => "octocat" },
},
]
}
get('/repositories/12345') {
assert :per_page => "100",
:page => "2"
json [
{ :number => 7,
:title => "Fourth",
:state => "open",
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-4", :label => "octocat:patch-4" },
:user => { :login => "octocat" },
},
]
}
"""
When I successfully run `hub pr list`
Then the output should contain exactly:
"""
#999 First
#102 Second
#13 Third
#7 Fourth\n
"""
Scenario: List pull requests with requested reviewers
Given the GitHub API server:
"""
get('/repos/github/hub/pulls') {
assert :per_page => "100",
:page => :no,
:sort => nil,
:direction => "desc"
json [
{ :number => 999,
:title => "First",
:state => "open",
:base => {
:ref => "master",
:label => "github:master",
:repo => { :owner => { :login => "github" } }
},
:head => { :ref => "patch-1", :label => "octocat:patch-1" },
:user => { :login => "octocat" },
:requested_reviewers => [
{ :login => "rey" },
],
:requested_teams => [
{ :slug => "troopers" },
{ :slug => "cantina-band" },
]
},
{ :number => 102,
:title => "Second",
:state => "open",
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-2", :label => "octocat:patch-2" },
:user => { :login => "octocat" },
:requested_reviewers => [
{ :login => "luke" },
{ :login => "jyn" },
]
},
]
}
"""
When I successfully run `hub pr list -f "%sC%>(8)%i %rs%n"`
Then the output should contain exactly:
"""
#999 rey, github/troopers, github/cantina-band
#102 luke, jyn\n
"""
@keep-ansi-escape-sequences
Scenario: List draft status
Given the GitHub API server:
"""
get('/repos/github/hub/pulls') {
halt 400 unless env['HTTP_ACCEPT'] == 'application/vnd.github.shadow-cat-preview+json;charset=utf-8'
json [
{ :number => 999,
:state => "open",
:draft => true,
:merged_at => nil,
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-2", :label => "octocat:patch-2" },
:user => { :login => "octocat" },
},
{ :number => 102,
:state => "open",
:draft => false,
:merged_at => nil,
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-1", :label => "octocat:patch-1" },
:user => { :login => "octocat" },
},
{ :number => 42,
:state => "closed",
:draft => false,
:merged_at => "2018-12-11T10:50:33Z",
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-3", :label => "octocat:patch-3" },
:user => { :login => "octocat" },
},
{ :number => 8,
:state => "closed",
:draft => false,
:merged_at => nil,
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-4", :label => "octocat:patch-4" },
:user => { :login => "octocat" },
},
]
}
"""
When I successfully run `hub pr list --format "%I %pC %pS %Creset%n" --color`
Then its output should contain exactly:
"""
999 \e[37m draft \e[m
102 \e[32m open \e[m
42 \e[35m merged \e[m
8 \e[31m closed \e[m\n
"""
When I successfully run `hub -c color.ui=always pr list --format "%I %pC %pS %Creset%n"`
Then its output should contain exactly:
"""
999 \e[37m draft \e[m
102 \e[32m open \e[m
42 \e[35m merged \e[m
8 \e[31m closed \e[m\n
"""
When I successfully run `hub -c color.ui=false pr list --format "%I %pC%pS%Creset%n" --color=auto`
Then its output should contain exactly:
"""
999 draft
102 open
42 merged
8 closed\n
"""
Scenario: Sort by number of comments ascending
Given the GitHub API server:
"""
get('/repos/github/hub/pulls') {
assert :sort => "comments",
:direction => "asc"
json []
}
"""
When I successfully run `hub pr list -o comments -^`
Then the output should contain exactly ""
Scenario: Filter by base and head
Given the GitHub API server:
"""
get('/repos/github/hub/pulls') {
assert :base => "develop",
:head => "github:patch-1"
json []
}
"""
When I successfully run `hub pr list -b develop -h patch-1`
Then the output should contain exactly ""
Scenario: Filter by head with owner
Given the GitHub API server:
"""
get('/repos/github/hub/pulls') {
assert :head => "mislav:patch-1"
json []
}
"""
When I successfully run `hub pr list -h mislav:patch-1`
Then the output should contain exactly ""
Scenario: Filter by merged state
Given the GitHub API server:
"""
get('/repos/github/hub/pulls') {
assert :state => "closed"
json [
{ :number => 999,
:title => "First",
:state => "closed",
:merged_at => "2018-12-11T10:50:33Z",
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-1", :label => "octocat:patch-1" },
:user => { :login => "octocat" },
},
{ :number => 102,
:title => "Second",
:state => "closed",
:merged_at => nil,
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-2", :label => "octocat:patch-2" },
:user => { :login => "octocat" },
},
{ :number => 13,
:title => "Third",
:state => "closed",
:merged_at => "2018-12-11T10:50:33Z",
:base => { :ref => "master", :label => "github:master" },
:head => { :ref => "patch-3", :label => "octocat:patch-3" },
:user => { :login => "octocat" },
},
]
}
"""
When I successfully run `hub pr list --state=merged`
Then the output should contain exactly:
"""
#999 First
#13 Third\n
"""