github.com/scorpionis/hub@v2.2.1+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;charset=utf-8'
    15          json :head => {
    16            :ref => "fixes",
    17            :repo => {
    18              :owner => { :login => "mislav" },
    19              :name => "jekyll",
    20              :private => false
    21            }
    22          }
    23        }
    24        """
    25      When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
    26      Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run
    27      And "git checkout -f --track -B mislav-fixes mislav/fixes -q" should be run
    28  
    29    Scenario: Pull request from a renamed fork
    30      Given the GitHub API server:
    31        """
    32        get('/repos/mojombo/jekyll/pulls/77') {
    33          json :head => {
    34            :ref => "fixes",
    35            :repo => {
    36              :owner => { :login => "mislav" },
    37              :name => "jekyll-blog",
    38              :private => false
    39            }
    40          }
    41        }
    42        """
    43      When I run `hub checkout https://github.com/mojombo/jekyll/pull/77`
    44      Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll-blog.git" should be run
    45      And "git checkout --track -B mislav-fixes mislav/fixes" should be run
    46  
    47    Scenario: Custom name for new branch
    48      Given the GitHub API server:
    49        """
    50        get('/repos/mojombo/jekyll/pulls/77') {
    51          json :head => {
    52            :ref => "fixes",
    53            :repo => {
    54              :owner => { :login => "mislav" },
    55              :name => "jekyll",
    56              :private => false
    57            }
    58          }
    59        }
    60        """
    61      When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 fixes-from-mislav`
    62      Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run
    63      And "git checkout --track -B fixes-from-mislav mislav/fixes" should be run
    64  
    65    Scenario: Private pull request
    66      Given the GitHub API server:
    67        """
    68        get('/repos/mojombo/jekyll/pulls/77') {
    69          json :head => {
    70            :ref => "fixes",
    71            :repo => {
    72              :owner => { :login => "mislav" },
    73              :name => "jekyll",
    74              :private => true
    75            }
    76          }
    77        }
    78        """
    79      When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
    80      Then "git remote add -f -t fixes mislav git@github.com:mislav/jekyll.git" should be run
    81      And "git checkout -f --track -B mislav-fixes mislav/fixes -q" should be run
    82  
    83    Scenario: Custom name for new branch
    84      Given the GitHub API server:
    85        """
    86        get('/repos/mojombo/jekyll/pulls/77') {
    87          json :head => {
    88            :ref => "fixes",
    89            :repo => {
    90              :owner => { :login => "mislav" },
    91              :name => "jekyll",
    92              :private => false
    93            }
    94          }
    95        }
    96        """
    97      When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 fixes-from-mislav`
    98      Then "git remote add -f -t fixes mislav git://github.com/mislav/jekyll.git" should be run
    99      And "git checkout --track -B fixes-from-mislav mislav/fixes" should be run
   100  
   101    Scenario: Remote for user already exists
   102      Given the GitHub API server:
   103        """
   104        get('/repos/mojombo/jekyll/pulls/77') {
   105          json :head => {
   106            :ref => "fixes",
   107            :repo => {
   108              :owner => { :login => "mislav" },
   109              :name => "jekyll",
   110              :private => false
   111            }
   112          }
   113        }
   114        """
   115      And the "mislav" remote has url "git://github.com/mislav/jekyll.git"
   116      When I run `hub checkout https://github.com/mojombo/jekyll/pull/77`
   117      Then "git remote set-branches --add mislav fixes" should be run
   118      And "git fetch mislav +refs/heads/fixes:refs/remotes/mislav/fixes" should be run
   119      And "git checkout --track -B mislav-fixes mislav/fixes" should be run