forked from mislav/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpr-show.feature
220 lines (207 loc) · 7.14 KB
/
pr-show.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
Feature: hub pr show
Background:
Given I am in "git://github.com/ashemesh/hub.git" git repo
And I am "ashemesh" on github.com with OAuth token "OTOKEN"
Scenario: Current branch
Given I am on the "topic" branch
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls'){
assert :state => "open",
:head => "ashemesh:topic"
json [
{ :html_url => "https://github.com/ashemesh/hub/pull/102" },
]
}
"""
When I successfully run `hub pr show`
Then "open https://github.com/ashemesh/hub/pull/102" should be run
Scenario: Current branch output URL
Given I am on the "topic" branch
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls'){
assert :state => "open",
:head => "ashemesh:topic"
json [
{ :html_url => "https://github.com/ashemesh/hub/pull/102" },
]
}
"""
When I successfully run `hub pr show -u`
Then "open https://github.com/ashemesh/hub/pull/102" should not be run
And the output should contain exactly:
"""
https://github.com/ashemesh/hub/pull/102\n
"""
Scenario: Format Current branch output URL
Given I am on the "topic" branch
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls'){
assert :state => "open",
:head => "ashemesh:topic"
json [{
:number => 102,
: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" },
],
:html_url => "https://github.com/ashemesh/hub/pull/102",
}]
}
"""
When I successfully run `hub pr show -f "%sC%>(8)%i %rs%n"`
Then "open https://github.com/ashemesh/hub/pull/102" should not be run
And the output should contain exactly:
"""
#102 rey, github/troopers, github/cantina-band\n
"""
Scenario: Current branch in fork
Given the "upstream" remote has url "[email protected]:github/hub.git"
And I am on the "topic" branch pushed to "origin/topic"
Given the GitHub API server:
"""
get('/repos/github/hub/pulls'){
assert :state => "open",
:head => "ashemesh:topic"
json [
{ :html_url => "https://github.com/github/hub/pull/102" },
]
}
"""
When I successfully run `hub pr show`
Then "open https://github.com/github/hub/pull/102" should be run
Scenario: Differently named branch in fork
Given the "upstream" remote has url "[email protected]:github/hub.git"
And I am on the "local-topic" branch with upstream "origin/remote-topic"
Given the GitHub API server:
"""
get('/repos/github/hub/pulls'){
assert :head => "ashemesh:remote-topic"
json [
{ :html_url => "https://github.com/github/hub/pull/102" },
]
}
"""
When I successfully run `hub pr show`
Then "open https://github.com/github/hub/pull/102" should be run
Scenario: Upstream configuration with HTTPS URL
Given I am on the "local-topic" branch
When I successfully run `git config branch.local-topic.remote https://github.com/octocat/hub.git`
When I successfully run `git config branch.local-topic.merge refs/remotes/remote-topic`
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls'){
assert :head => "octocat:remote-topic"
json [
{ :html_url => "https://github.com/github/hub/pull/102" },
]
}
"""
When I successfully run `hub pr show`
Then "open https://github.com/github/hub/pull/102" should be run
Scenario: Upstream configuration with SSH URL
Given I am on the "local-topic" branch
When I successfully run `git config branch.local-topic.remote [email protected]:octocat/hub.git`
When I successfully run `git config branch.local-topic.merge refs/remotes/remote-topic`
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls'){
assert :head => "octocat:remote-topic"
json [
{ :html_url => "https://github.com/github/hub/pull/102" },
]
}
"""
When I successfully run `hub pr show`
Then "open https://github.com/github/hub/pull/102" should be run
Scenario: Explicit head branch
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls'){
assert :state => "open",
:head => "ashemesh:topic"
json [
{ :html_url => "https://github.com/ashemesh/hub/pull/102" },
]
}
"""
When I successfully run `hub pr show --head topic`
Then "open https://github.com/ashemesh/hub/pull/102" should be run
Scenario: Explicit head branch with owner
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls'){
assert :state => "open",
:head => "github:topic"
json [
{ :html_url => "https://github.com/ashemesh/hub/pull/102" },
]
}
"""
When I successfully run `hub pr show --head github:topic`
Then "open https://github.com/ashemesh/hub/pull/102" should be run
Scenario: No pull request found
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls'){
json []
}
"""
When I run `hub pr show --head topic`
Then the exit status should be 1
And the stderr should contain exactly:
"""
no open pull requests found for branch 'ashemesh:topic'\n
"""
Scenario: Show pull request by number
When I successfully run `hub pr show 102`
Then "open https://github.com/ashemesh/hub/pull/102" should be run
Scenario: Format pull request by number
Given the GitHub API server:
"""
get('/repos/ashemesh/hub/pulls/102') {
json :number => 102,
: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" },
]
}
"""
When I successfully run `hub pr show 102 -f "%sC%>(8)%i %rs%n"`
Then "open https://github.com/ashemesh/hub/pull/102" should not be run
And the output should contain exactly:
"""
#102 rey, github/troopers, github/cantina-band\n
"""
Scenario: Show pull request by invalid number
When I run `hub pr show XYZ`
Then the exit status should be 1
And the stderr should contain exactly:
"""
invalid pull request number: 'XYZ'\n
"""