github.com/jingweno/gh@v2.1.1-0.20221007190738-04a7985fa9a1+incompatible/features/checkout.feature (about) 1 Feature: hub checkout <PULLREQ-URL> 2 Background: 3 Given I am in "git://github.com/mojombo/jekyll.git" git repo 4 And I am "mislav" on github.com with OAuth token "OTOKEN" 5 6 Scenario: Unchanged command 7 When I run `hub checkout master` 8 Then "git checkout master" should be run 9 10 Scenario: Checkout a pull request 11 Given the GitHub API server: 12 """ 13 get('/repos/mojombo/jekyll/pulls/77') { 14 halt 406 unless request.env['HTTP_ACCEPT'] == 'application/vnd.github.v3+json' 15 json :head => { 16 :label => 'mislav:fixes', 17 :repo => { :id => 1, :private => false } 18 } 19 } 20 """ 21 When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q` 22 Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run 23 And "git checkout -f --track -B mislav-fixes mislav/fixes -q" should be run 24 25 Scenario: Custom name for new branch 26 Given the GitHub API server: 27 """ 28 get('/repos/mojombo/jekyll/pulls/77') { 29 json :head => { 30 :label => 'mislav:fixes', 31 :repo => { :id => 1, :private => false } 32 } 33 } 34 """ 35 When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 fixes-from-mislav` 36 Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run 37 And "git checkout --track -B fixes-from-mislav mislav/fixes" should be run 38 39 Scenario: Private pull request 40 Given the GitHub API server: 41 """ 42 get('/repos/mojombo/jekyll/pulls/77') { 43 json :head => { 44 :label => 'mislav:fixes', 45 :repo => { :id => 1, :private => true } 46 } 47 } 48 """ 49 When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q` 50 Then "git remote add -f -t fixes mislav git@github.com:mislav/jekyll.git" should be run 51 And "git checkout -f --track -B mislav-fixes mislav/fixes -q" should be run 52 53 Scenario: Custom name for new branch 54 Given the GitHub API server: 55 """ 56 get('/repos/mojombo/jekyll/pulls/77') { 57 json :head => { 58 :label => 'mislav:fixes', 59 :repo => { :id => 1, :private => false } 60 } 61 } 62 """ 63 When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 fixes-from-mislav` 64 Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run 65 And "git checkout --track -B fixes-from-mislav mislav/fixes" should be run 66 67 Scenario: Remote for user already exists 68 Given the GitHub API server: 69 """ 70 get('/repos/mojombo/jekyll/pulls/77') { 71 json :head => { 72 :label => 'mislav:fixes', 73 :repo => { :id => 1, :private => false } 74 } 75 } 76 """ 77 And the "mislav" remote has url "git://github.com/mislav/jekyll.git" 78 When I run `hub checkout https://github.com/mojombo/jekyll/pull/77` 79 Then "git remote set-branches --add mislav fixes" should be run 80 And "git fetch mislav +refs/heads/fixes:refs/remotes/mislav/fixes" should be run 81 And "git checkout --track -B mislav-fixes mislav/fixes" should be run