github.com/pengwynn/gh@v1.0.1-0.20140118055701-14327ca3942e/features/pull_request.feature (about) 1 Feature: hub pull-request 2 Background: 3 Given I am in "git://github.com/mislav/coral.git" git repo 4 And I am "mislav" on github.com with OAuth token "OTOKEN" 5 And the git commit editor is "vim" 6 7 Scenario: Detached HEAD 8 Given I am in detached HEAD 9 When I run `hub pull-request` 10 Then the stderr should contain "Aborted: not currently on any branch.\n" 11 And the exit status should be 1 12 13 Scenario: Non-GitHub repo 14 Given the "origin" remote has url "mygh:Manganeez/repo.git" 15 When I run `hub pull-request` 16 Then the stderr should contain "Aborted: the origin remote doesn't point to a GitHub repository.\n" 17 And the exit status should be 1 18 19 Scenario: Create pull request respecting "insteadOf" configuration 20 Given the "origin" remote has url "mygh:Manganeez/repo.git" 21 When I successfully run `git config url."git@github.com:".insteadOf mygh:` 22 Given the GitHub API server: 23 """ 24 post('/repos/Manganeez/repo/pulls') { 25 assert :base => 'master', 26 :head => 'Manganeez:master', 27 :title => 'here we go' 28 json :html_url => "https://github.com/Manganeez/repo/pull/12" 29 } 30 """ 31 When I successfully run `hub pull-request -m "here we go"` 32 Then the output should contain exactly "https://github.com/Manganeez/repo/pull/12\n" 33 34 Scenario: With Unicode characters 35 Given the GitHub API server: 36 """ 37 post('/repos/mislav/coral/pulls') { 38 assert :title => 'ăéñøü' 39 json :html_url => "the://url" 40 } 41 """ 42 When I successfully run `hub pull-request -m ăéñøü` 43 Then the output should contain exactly "the://url\n" 44 45 @wip 46 Scenario: Deprecated title argument 47 Given the GitHub API server: 48 """ 49 post('/repos/mislav/coral/pulls') { 50 halt 422 if params[:title] != 'mytitle' 51 json :html_url => "the://url" 52 } 53 """ 54 When I successfully run `hub pull-request mytitle` 55 Then the stderr should contain exactly: 56 """ 57 hub: Specifying pull request title without a flag is deprecated. 58 Please use one of `-m' or `-F' options.\n 59 """ 60 And the stdout should contain exactly "the://url\n" 61 62 Scenario: Non-existing base 63 Given the GitHub API server: 64 """ 65 post('/repos/origin/coral/pulls') { halt 404, json(:error => 'error') } 66 """ 67 When I run `hub pull-request -b origin:master -m here` 68 Then the exit status should be 1 69 #Then the stderr should contain: 70 #""" 71 #Error creating pull request: Not Found (HTTP 404) 72 #Are you sure that github.com/origin/coral exists? 73 #""" 74 Then the stderr should contain: 75 """ 76 404 - Error: error 77 """ 78 79 Scenario: Supplies User-Agent string to API calls 80 Given the GitHub API server: 81 """ 82 post('/repos/mislav/coral/pulls') { 83 halt 400 unless request.user_agent.include?('Octokit') 84 json :html_url => "the://url" 85 } 86 """ 87 When I successfully run `hub pull-request -m useragent` 88 Then the output should contain exactly "the://url\n" 89 90 Scenario: Text editor adds title and body 91 Given the text editor adds: 92 """ 93 This title comes from vim! 94 95 This body as well. 96 """ 97 Given the GitHub API server: 98 """ 99 post('/repos/mislav/coral/pulls') { 100 assert :title => 'This title comes from vim!', 101 :body => 'This body as well.' 102 json :html_url => "https://github.com/mislav/coral/pull/12" 103 } 104 """ 105 When I successfully run `hub pull-request` 106 Then the output should contain exactly "https://github.com/mislav/coral/pull/12\n" 107 And the file ".git/PULLREQ_EDITMSG" should not exist 108 109 @wip 110 Scenario: Failed pull request preserves previous message 111 Given the text editor adds: 112 """ 113 This title will fail 114 """ 115 Given the GitHub API server: 116 """ 117 post('/repos/mislav/coral/pulls') { 118 if params[:title].include?("fail") 119 status 422 120 json(:message => "I haz fail!") 121 return 122 end 123 124 assert :body => "This title will fail", 125 :title => "But this title will prevail" 126 json :html_url => "https://github.com/mislav/coral/pull/12" 127 } 128 """ 129 When I run `hub pull-request` 130 Then the exit status should be 1 131 And the stderr should contain exactly: 132 """ 133 422 - I haz fail!\n 134 """ 135 Given the text editor adds: 136 """ 137 But this title will prevail 138 """ 139 When I successfully run `hub pull-request` 140 Then the file ".git/PULLREQ_EDITMSG" should not exist 141 142 @wip 143 Scenario: Ignore outdated PULLREQ_EDITMSG 144 Given the GitHub API server: 145 """ 146 post('/repos/mislav/coral/pulls') { 147 assert :title => "Added interactively", :body => nil 148 json :html_url => "https://github.com/mislav/coral/pull/12" 149 } 150 """ 151 And a file named ".git/PULLREQ_EDITMSG" with: 152 """ 153 Outdated message from old version of hub 154 """ 155 Given the file named ".git/PULLREQ_EDITMSG" is older than hub source 156 And the text editor adds: 157 """ 158 Added interactively 159 """ 160 When I successfully run `hub pull-request` 161 Then the file ".git/PULLREQ_EDITMSG" should not exist 162 163 Scenario: Text editor fails 164 Given the text editor exits with error status 165 And an empty file named ".git/PULLREQ_EDITMSG" 166 When I run `hub pull-request` 167 Then the stderr should contain "error using text editor for editing message" 168 And the exit status should be 1 169 And the file ".git/PULLREQ_EDITMSG" should not exist 170 171 Scenario: Title and body from file 172 Given the GitHub API server: 173 """ 174 post('/repos/mislav/coral/pulls') { 175 assert :title => 'Title from file', 176 :body => "Body from file as well.\n\nMultiline, even!" 177 json :html_url => "https://github.com/mislav/coral/pull/12" 178 } 179 """ 180 And a file named "pullreq-msg" with: 181 """ 182 Title from file 183 184 Body from file as well. 185 186 Multiline, even! 187 """ 188 When I successfully run `hub pull-request -F pullreq-msg` 189 Then the output should contain exactly "https://github.com/mislav/coral/pull/12\n" 190 And the file ".git/PULLREQ_EDITMSG" should not exist 191 192 Scenario: Title and body from stdin 193 Given the GitHub API server: 194 """ 195 post('/repos/mislav/coral/pulls') { 196 assert :title => 'Unix piping is great', 197 :body => 'Just look at this' 198 json :html_url => "https://github.com/mislav/coral/pull/12" 199 } 200 """ 201 When I run `hub pull-request -F -` interactively 202 And I pass in: 203 """ 204 Unix piping is great 205 206 Just look at this 207 """ 208 Then the output should contain exactly "https://github.com/mislav/coral/pull/12\n" 209 And the exit status should be 0 210 And the file ".git/PULLREQ_EDITMSG" should not exist 211 212 Scenario: Title and body from command-line argument 213 Given the GitHub API server: 214 """ 215 post('/repos/mislav/coral/pulls') { 216 assert :title => 'I am just a pull', 217 :body => 'A little pull' 218 json :html_url => "https://github.com/mislav/coral/pull/12" 219 } 220 """ 221 When I successfully run `hub pull-request -m "I am just a pull\n\nA little pull"` 222 Then the output should contain exactly "https://github.com/mislav/coral/pull/12\n" 223 And the file ".git/PULLREQ_EDITMSG" should not exist 224 225 Scenario: Error when implicit head is the same as base 226 Given I am on the "master" branch with upstream "origin/master" 227 When I run `hub pull-request` 228 Then the stderr should contain exactly: 229 """ 230 Aborted: head branch is the same as base ("master") 231 (use `-h <branch>` to specify an explicit pull request head)\n 232 """ 233 234 Scenario: Explicit head 235 Given I am on the "master" branch 236 Given the GitHub API server: 237 """ 238 post('/repos/mislav/coral/pulls') { 239 assert :head => 'mislav:feature' 240 json :html_url => "the://url" 241 } 242 """ 243 When I successfully run `hub pull-request -h feature -m message` 244 Then the output should contain exactly "the://url\n" 245 246 Scenario: Explicit head with owner 247 Given I am on the "master" branch 248 Given the GitHub API server: 249 """ 250 post('/repos/mislav/coral/pulls') { 251 assert :head => 'mojombo:feature' 252 json :html_url => "the://url" 253 } 254 """ 255 When I successfully run `hub pull-request -h mojombo:feature -m message` 256 Then the output should contain exactly "the://url\n" 257 258 Scenario: Explicit base 259 Given I am on the "feature" branch 260 Given the GitHub API server: 261 """ 262 post('/repos/mislav/coral/pulls') { 263 assert :base => 'develop' 264 json :html_url => "the://url" 265 } 266 """ 267 When I successfully run `hub pull-request -b develop -m message` 268 Then the output should contain exactly "the://url\n" 269 270 Scenario: Implicit base by detecting main branch 271 Given the default branch for "origin" is "develop" 272 And I am on the "master" branch 273 Given the GitHub API server: 274 """ 275 post('/repos/mislav/coral/pulls') { 276 assert :base => 'develop', 277 :head => 'mislav:master' 278 json :html_url => "the://url" 279 } 280 """ 281 When I successfully run `hub pull-request -m message` 282 Then the output should contain exactly "the://url\n" 283 284 Scenario: Explicit base with owner 285 Given I am on the "master" branch 286 Given the GitHub API server: 287 """ 288 post('/repos/mojombo/coral/pulls') { 289 assert :base => 'develop' 290 json :html_url => "the://url" 291 } 292 """ 293 When I successfully run `hub pull-request -b mojombo:develop -m message` 294 Then the output should contain exactly "the://url\n" 295 296 Scenario: Explicit base with owner and repo name 297 Given I am on the "master" branch 298 Given the GitHub API server: 299 """ 300 post('/repos/mojombo/coralify/pulls') { 301 assert :base => 'develop' 302 json :html_url => "the://url" 303 } 304 """ 305 When I successfully run `hub pull-request -b mojombo/coralify:develop -m message` 306 Then the output should contain exactly "the://url\n" 307 308 Scenario: Error when there are unpushed commits 309 Given I am on the "feature" branch with upstream "origin/feature" 310 When I make 2 commits 311 And I run `hub pull-request` 312 Then the stderr should contain exactly: 313 """ 314 Aborted: 2 commits are not yet pushed to origin/feature 315 (use `-f` to force submit a pull request anyway)\n 316 """ 317 318 Scenario: Ignore unpushed commits with `-f` 319 Given I am on the "feature" branch with upstream "origin/feature" 320 Given the GitHub API server: 321 """ 322 post('/repos/mislav/coral/pulls') { 323 assert :head => 'mislav:feature' 324 json :html_url => "the://url" 325 } 326 """ 327 When I make 2 commits 328 And I successfully run `hub pull-request -f -m message` 329 Then the output should contain exactly "the://url\n" 330 331 Scenario: Pull request fails on the server 332 Given I am on the "feature" branch with upstream "origin/feature" 333 Given the GitHub API server: 334 """ 335 post('/repos/mislav/coral/pulls') { 336 status 422 337 json(:message => "I haz fail!") 338 } 339 """ 340 When I run `hub pull-request -m message` 341 Then the stderr should contain exactly: 342 """ 343 422 - I haz fail!\n 344 """ 345 346 Scenario: Convert issue to pull request 347 Given I am on the "feature" branch with upstream "origin/feature" 348 Given the GitHub API server: 349 """ 350 post('/repos/mislav/coral/pulls') { 351 assert :issue => '92' 352 json :html_url => "https://github.com/mislav/coral/pull/92" 353 } 354 """ 355 When I successfully run `hub pull-request -i 92` 356 Then the output should contain exactly "https://github.com/mislav/coral/pull/92\n" 357 358 Scenario: Convert issue URL to pull request 359 Given I am on the "feature" branch with upstream "origin/feature" 360 Given the GitHub API server: 361 """ 362 post('/repos/mislav/coral/pulls') { 363 assert :issue => '92' 364 json :html_url => "https://github.com/mislav/coral/pull/92" 365 } 366 """ 367 When I successfully run `hub pull-request https://github.com/mislav/coral/issues/92` 368 Then the output should contain exactly: 369 """ 370 https://github.com/mislav/coral/pull/92 371 Warning: Issue to pull request conversion is deprecated and might not work in the future.\n 372 """ 373 374 Scenario: Enterprise host 375 Given the "origin" remote has url "git@git.my.org:mislav/coral.git" 376 And I am "mislav" on git.my.org with OAuth token "FITOKEN" 377 And "git.my.org" is a whitelisted Enterprise host 378 Given the GitHub API server: 379 """ 380 post('/api/v3/repos/mislav/coral/pulls') { 381 json :html_url => "the://url" 382 } 383 """ 384 When I successfully run `hub pull-request -m enterprisey` 385 Then the output should contain exactly "the://url\n" 386 387 Scenario: Create pull request from branch on the same remote 388 Given the "origin" remote has url "git://github.com/github/coral.git" 389 And the "mislav" remote has url "git://github.com/mislav/coral.git" 390 And I am on the "feature" branch pushed to "origin/feature" 391 Given the GitHub API server: 392 """ 393 post('/repos/github/coral/pulls') { 394 assert :base => 'master', 395 :head => 'github:feature', 396 :title => 'hereyougo' 397 json :html_url => "the://url" 398 } 399 """ 400 When I successfully run `hub pull-request -m hereyougo` 401 Then the output should contain exactly "the://url\n" 402 403 Scenario: Create pull request from branch on the personal fork 404 Given the "origin" remote has url "git://github.com/github/coral.git" 405 And the "doge" remote has url "git://github.com/mislav/coral.git" 406 And I am on the "feature" branch pushed to "doge/feature" 407 Given the GitHub API server: 408 """ 409 post('/repos/github/coral/pulls') { 410 assert :base => 'master', 411 :head => 'mislav:feature', 412 :title => 'hereyougo' 413 json :html_url => "the://url" 414 } 415 """ 416 When I successfully run `hub pull-request -m hereyougo` 417 Then the output should contain exactly "the://url\n" 418 419 @wip 420 Scenario: Create pull request to "upstream" remote 421 Given the "upstream" remote has url "git://github.com/github/coral.git" 422 And I am on the "master" branch pushed to "origin/master" 423 Given the GitHub API server: 424 """ 425 post('/repos/github/coral/pulls') { 426 assert :base => 'master', 427 :head => 'mislav:master', 428 :title => 'hereyougo' 429 json :html_url => "the://url" 430 } 431 """ 432 When I successfully run `hub pull-request -m hereyougo` 433 Then the output should contain exactly "the://url\n"