github.com/jingweno/gh@v2.1.1-0.20221007190738-04a7985fa9a1+incompatible/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 Scenario: Text editor adds title and body with multiple lines 110 Given the text editor adds: 111 """ 112 113 114 This title is on the third line 115 116 117 This body 118 119 120 has multiple 121 lines. 122 123 """ 124 Given the GitHub API server: 125 """ 126 post('/repos/mislav/coral/pulls') { 127 assert :title => 'This title is on the third line', 128 :body => "This body\n\n\nhas multiple\nlines." 129 json :html_url => "https://github.com/mislav/coral/pull/12" 130 } 131 """ 132 When I successfully run `hub pull-request` 133 Then the output should contain exactly "https://github.com/mislav/coral/pull/12\n" 134 And the file ".git/PULLREQ_EDITMSG" should not exist 135 136 @wip 137 Scenario: Failed pull request preserves previous message 138 Given the text editor adds: 139 """ 140 This title will fail 141 """ 142 Given the GitHub API server: 143 """ 144 post('/repos/mislav/coral/pulls') { 145 if params[:title].include?("fail") 146 status 422 147 json(:message => "I haz fail!") 148 return 149 end 150 151 assert :body => "This title will fail", 152 :title => "But this title will prevail" 153 json :html_url => "https://github.com/mislav/coral/pull/12" 154 } 155 """ 156 When I run `hub pull-request` 157 Then the exit status should be 1 158 And the stderr should contain exactly: 159 """ 160 422 - I haz fail!\n 161 """ 162 Given the text editor adds: 163 """ 164 But this title will prevail 165 """ 166 When I successfully run `hub pull-request` 167 Then the file ".git/PULLREQ_EDITMSG" should not exist 168 169 @wip 170 Scenario: Ignore outdated PULLREQ_EDITMSG 171 Given the GitHub API server: 172 """ 173 post('/repos/mislav/coral/pulls') { 174 assert :title => "Added interactively", :body => nil 175 json :html_url => "https://github.com/mislav/coral/pull/12" 176 } 177 """ 178 And a file named ".git/PULLREQ_EDITMSG" with: 179 """ 180 Outdated message from old version of hub 181 """ 182 Given the file named ".git/PULLREQ_EDITMSG" is older than hub source 183 And the text editor adds: 184 """ 185 Added interactively 186 """ 187 When I successfully run `hub pull-request` 188 Then the file ".git/PULLREQ_EDITMSG" should not exist 189 190 Scenario: Text editor fails 191 Given the text editor exits with error status 192 And an empty file named ".git/PULLREQ_EDITMSG" 193 When I run `hub pull-request` 194 Then the stderr should contain "error using text editor for editing message" 195 And the exit status should be 1 196 And the file ".git/PULLREQ_EDITMSG" should not exist 197 198 Scenario: Title and body from file 199 Given the GitHub API server: 200 """ 201 post('/repos/mislav/coral/pulls') { 202 assert :title => 'Title from file', 203 :body => "Body from file as well.\n\nMultiline, even!" 204 json :html_url => "https://github.com/mislav/coral/pull/12" 205 } 206 """ 207 And a file named "pullreq-msg" with: 208 """ 209 Title from file 210 211 Body from file as well. 212 213 Multiline, even! 214 """ 215 When I successfully run `hub pull-request -F pullreq-msg` 216 Then the output should contain exactly "https://github.com/mislav/coral/pull/12\n" 217 And the file ".git/PULLREQ_EDITMSG" should not exist 218 219 Scenario: Title and body from stdin 220 Given the GitHub API server: 221 """ 222 post('/repos/mislav/coral/pulls') { 223 assert :title => 'Unix piping is great', 224 :body => 'Just look at this' 225 json :html_url => "https://github.com/mislav/coral/pull/12" 226 } 227 """ 228 When I run `hub pull-request -F -` interactively 229 And I pass in: 230 """ 231 Unix piping is great 232 233 Just look at this 234 """ 235 Then the output should contain exactly "https://github.com/mislav/coral/pull/12\n" 236 And the exit status should be 0 237 And the file ".git/PULLREQ_EDITMSG" should not exist 238 239 Scenario: Title and body from command-line argument 240 Given the GitHub API server: 241 """ 242 post('/repos/mislav/coral/pulls') { 243 assert :title => 'I am just a pull', 244 :body => 'A little pull' 245 json :html_url => "https://github.com/mislav/coral/pull/12" 246 } 247 """ 248 When I successfully run `hub pull-request -m "I am just a pull\n\nA little pull"` 249 Then the output should contain exactly "https://github.com/mislav/coral/pull/12\n" 250 And the file ".git/PULLREQ_EDITMSG" should not exist 251 252 Scenario: Error when implicit head is the same as base 253 Given I am on the "master" branch with upstream "origin/master" 254 When I run `hub pull-request` 255 Then the stderr should contain exactly: 256 """ 257 Aborted: head branch is the same as base ("master") 258 (use `-h <branch>` to specify an explicit pull request head)\n 259 """ 260 261 Scenario: Explicit head 262 Given I am on the "master" branch 263 Given the GitHub API server: 264 """ 265 post('/repos/mislav/coral/pulls') { 266 assert :head => 'mislav:feature' 267 json :html_url => "the://url" 268 } 269 """ 270 When I successfully run `hub pull-request -h feature -m message` 271 Then the output should contain exactly "the://url\n" 272 273 Scenario: Explicit head with owner 274 Given I am on the "master" branch 275 Given the GitHub API server: 276 """ 277 post('/repos/mislav/coral/pulls') { 278 assert :head => 'mojombo:feature' 279 json :html_url => "the://url" 280 } 281 """ 282 When I successfully run `hub pull-request -h mojombo:feature -m message` 283 Then the output should contain exactly "the://url\n" 284 285 Scenario: Explicit base 286 Given I am on the "feature" branch 287 Given the GitHub API server: 288 """ 289 post('/repos/mislav/coral/pulls') { 290 assert :base => 'develop' 291 json :html_url => "the://url" 292 } 293 """ 294 When I successfully run `hub pull-request -b develop -m message` 295 Then the output should contain exactly "the://url\n" 296 297 Scenario: Implicit base by detecting main branch 298 Given the default branch for "origin" is "develop" 299 And I am on the "master" branch 300 Given the GitHub API server: 301 """ 302 post('/repos/mislav/coral/pulls') { 303 assert :base => 'develop', 304 :head => 'mislav:master' 305 json :html_url => "the://url" 306 } 307 """ 308 When I successfully run `hub pull-request -m message` 309 Then the output should contain exactly "the://url\n" 310 311 Scenario: Explicit base with owner 312 Given I am on the "master" branch 313 Given the GitHub API server: 314 """ 315 post('/repos/mojombo/coral/pulls') { 316 assert :base => 'develop' 317 json :html_url => "the://url" 318 } 319 """ 320 When I successfully run `hub pull-request -b mojombo:develop -m message` 321 Then the output should contain exactly "the://url\n" 322 323 Scenario: Explicit base with owner and repo name 324 Given I am on the "master" branch 325 Given the GitHub API server: 326 """ 327 post('/repos/mojombo/coralify/pulls') { 328 assert :base => 'develop' 329 json :html_url => "the://url" 330 } 331 """ 332 When I successfully run `hub pull-request -b mojombo/coralify:develop -m message` 333 Then the output should contain exactly "the://url\n" 334 335 Scenario: Error when there are unpushed commits 336 Given I am on the "feature" branch with upstream "origin/feature" 337 When I make 2 commits 338 And I run `hub pull-request` 339 Then the stderr should contain exactly: 340 """ 341 Aborted: 2 commits are not yet pushed to origin/feature 342 (use `-f` to force submit a pull request anyway)\n 343 """ 344 345 Scenario: Ignore unpushed commits with `-f` 346 Given I am on the "feature" branch with upstream "origin/feature" 347 Given the GitHub API server: 348 """ 349 post('/repos/mislav/coral/pulls') { 350 assert :head => 'mislav:feature' 351 json :html_url => "the://url" 352 } 353 """ 354 When I make 2 commits 355 And I successfully run `hub pull-request -f -m message` 356 Then the output should contain exactly "the://url\n" 357 358 Scenario: Pull request fails on the server 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 status 422 364 json(:message => "I haz fail!") 365 } 366 """ 367 When I run `hub pull-request -m message` 368 Then the stderr should contain exactly: 369 """ 370 422 - I haz fail!\n 371 """ 372 373 Scenario: Convert issue to pull request 374 Given I am on the "feature" branch with upstream "origin/feature" 375 Given the GitHub API server: 376 """ 377 post('/repos/mislav/coral/pulls') { 378 assert :issue => '92' 379 json :html_url => "https://github.com/mislav/coral/pull/92" 380 } 381 """ 382 When I successfully run `hub pull-request -i 92` 383 Then the output should contain exactly "https://github.com/mislav/coral/pull/92\n" 384 385 Scenario: Convert issue URL to pull request 386 Given I am on the "feature" branch with upstream "origin/feature" 387 Given the GitHub API server: 388 """ 389 post('/repos/mislav/coral/pulls') { 390 assert :issue => '92' 391 json :html_url => "https://github.com/mislav/coral/pull/92" 392 } 393 """ 394 When I successfully run `hub pull-request https://github.com/mislav/coral/issues/92` 395 Then the output should contain exactly: 396 """ 397 https://github.com/mislav/coral/pull/92 398 Warning: Issue to pull request conversion is deprecated and might not work in the future.\n 399 """ 400 401 Scenario: Enterprise host 402 Given the "origin" remote has url "git@git.my.org:mislav/coral.git" 403 And I am "mislav" on git.my.org with OAuth token "FITOKEN" 404 And "git.my.org" is a whitelisted Enterprise host 405 Given the GitHub API server: 406 """ 407 post('/api/v3/repos/mislav/coral/pulls') { 408 json :html_url => "the://url" 409 } 410 """ 411 When I successfully run `hub pull-request -m enterprisey` 412 Then the output should contain exactly "the://url\n" 413 414 Scenario: Create pull request from branch on the same remote 415 Given the "origin" remote has url "git://github.com/github/coral.git" 416 And the "mislav" remote has url "git://github.com/mislav/coral.git" 417 And I am on the "feature" branch pushed to "origin/feature" 418 Given the GitHub API server: 419 """ 420 post('/repos/github/coral/pulls') { 421 assert :base => 'master', 422 :head => 'github:feature', 423 :title => 'hereyougo' 424 json :html_url => "the://url" 425 } 426 """ 427 When I successfully run `hub pull-request -m hereyougo` 428 Then the output should contain exactly "the://url\n" 429 430 Scenario: Create pull request from branch on the personal fork 431 Given the "origin" remote has url "git://github.com/github/coral.git" 432 And the "doge" remote has url "git://github.com/mislav/coral.git" 433 And I am on the "feature" branch pushed to "doge/feature" 434 Given the GitHub API server: 435 """ 436 post('/repos/github/coral/pulls') { 437 assert :base => 'master', 438 :head => 'mislav:feature', 439 :title => 'hereyougo' 440 json :html_url => "the://url" 441 } 442 """ 443 When I successfully run `hub pull-request -m hereyougo` 444 Then the output should contain exactly "the://url\n" 445 446 @wip 447 Scenario: Create pull request to "upstream" remote 448 Given the "upstream" remote has url "git://github.com/github/coral.git" 449 And I am on the "master" branch pushed to "origin/master" 450 Given the GitHub API server: 451 """ 452 post('/repos/github/coral/pulls') { 453 assert :base => 'master', 454 :head => 'mislav:master', 455 :title => 'hereyougo' 456 json :html_url => "the://url" 457 } 458 """ 459 When I successfully run `hub pull-request -m hereyougo` 460 Then the output should contain exactly "the://url\n"