2013-05-11 16:39:06 +04:00
|
|
|
Feature: hub checkout <PULLREQ-URL>
|
|
|
|
Background:
|
|
|
|
Given I am in "git://github.com/mojombo/jekyll.git" git repo
|
|
|
|
And I am "mislav" on github.com with OAuth token "OTOKEN"
|
|
|
|
|
|
|
|
Scenario: Unchanged command
|
|
|
|
When I run `hub checkout master`
|
|
|
|
Then "git checkout master" should be run
|
|
|
|
|
|
|
|
Scenario: Checkout a pull request
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-24 18:53:52 +03:00
|
|
|
halt 415 unless request.accept?('application/vnd.github.v3+json')
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2015-02-23 08:44:36 +03:00
|
|
|
:ref => "fixes",
|
2015-01-21 09:53:01 +03:00
|
|
|
:repo => {
|
2015-02-26 09:43:23 +03:00
|
|
|
:owner => { :login => "mislav" },
|
2015-02-23 08:44:36 +03:00
|
|
|
:name => "jekyll",
|
2015-01-21 09:53:01 +03:00
|
|
|
:private => false
|
|
|
|
}
|
2016-08-20 23:49:56 +03:00
|
|
|
}, :base => {
|
|
|
|
:repo => {
|
|
|
|
:name => 'jekyll',
|
|
|
|
:html_url => 'https://github.com/mojombo/jekyll',
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
2017-02-03 10:53:44 +03:00
|
|
|
}, :maintainer_can_modify => false
|
2013-05-11 16:39:06 +04:00
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
|
2016-10-03 19:43:10 +03:00
|
|
|
Then "git fetch origin refs/pull/77/head:mislav-fixes" should be run
|
2016-08-18 22:12:34 +03:00
|
|
|
And "git checkout -f mislav-fixes -q" should be run
|
2017-02-04 02:54:44 +03:00
|
|
|
And "mislav-fixes" should merge "refs/pull/77/head" from remote "origin"
|
2013-05-11 16:39:06 +04:00
|
|
|
|
2016-08-20 23:49:56 +03:00
|
|
|
Scenario: No matching remotes for pull request base
|
2015-01-21 09:53:01 +03:00
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
2016-08-20 23:49:56 +03:00
|
|
|
get('/repos/mislav/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :base => {
|
2015-01-21 09:53:01 +03:00
|
|
|
:repo => {
|
2016-08-20 23:49:56 +03:00
|
|
|
:name => 'jekyll',
|
|
|
|
:html_url => 'https://github.com/mislav/jekyll',
|
2015-02-26 09:43:23 +03:00
|
|
|
:owner => { :login => "mislav" },
|
2015-01-21 09:53:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
2016-08-20 23:49:56 +03:00
|
|
|
When I run `hub checkout -f https://github.com/mislav/jekyll/pull/77 -q`
|
|
|
|
Then the exit status should be 1
|
|
|
|
And the stderr should contain exactly:
|
2013-05-11 16:39:06 +04:00
|
|
|
"""
|
2016-08-20 23:49:56 +03:00
|
|
|
could not find git remote for mislav/jekyll\n
|
2013-05-11 16:39:06 +04:00
|
|
|
"""
|
|
|
|
|
2016-08-20 23:49:56 +03:00
|
|
|
Scenario: Custom name for new branch
|
2013-05-11 16:39:06 +04:00
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2015-02-23 08:44:36 +03:00
|
|
|
:ref => "fixes",
|
2015-01-21 09:53:01 +03:00
|
|
|
:repo => {
|
2015-02-23 08:44:36 +03:00
|
|
|
:name => "jekyll",
|
2016-08-20 23:49:56 +03:00
|
|
|
:owner => { :login => "mislav" },
|
2015-01-21 09:53:01 +03:00
|
|
|
}
|
2016-08-20 23:49:56 +03:00
|
|
|
}, :base => {
|
2015-01-21 09:53:01 +03:00
|
|
|
:repo => {
|
2016-08-20 23:49:56 +03:00
|
|
|
:name => 'jekyll',
|
|
|
|
:html_url => 'https://github.com/mojombo/jekyll',
|
|
|
|
:owner => { :login => "mojombo" },
|
2015-01-21 09:53:01 +03:00
|
|
|
}
|
2017-02-03 10:53:44 +03:00
|
|
|
}, :maintainer_can_modify => false
|
2013-05-11 16:39:06 +04:00
|
|
|
}
|
|
|
|
"""
|
2016-08-20 23:49:56 +03:00
|
|
|
When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 fixes-from-mislav`
|
2016-10-03 19:43:10 +03:00
|
|
|
Then "git fetch origin refs/pull/77/head:fixes-from-mislav" should be run
|
2016-08-20 23:49:56 +03:00
|
|
|
And "git checkout fixes-from-mislav" should be run
|
2017-02-04 02:54:44 +03:00
|
|
|
And "fixes-from-mislav" should merge "refs/pull/77/head" from remote "origin"
|
2016-08-21 01:00:13 +03:00
|
|
|
|
|
|
|
Scenario: Same-repo
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2016-08-21 01:00:13 +03:00
|
|
|
:ref => "fixes",
|
|
|
|
:repo => {
|
|
|
|
:name => "jekyll",
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}, :base => {
|
|
|
|
:repo => {
|
|
|
|
:name => "jekyll",
|
|
|
|
:html_url => "https://github.com/mojombo/jekyll",
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
|
|
|
|
Then "git fetch origin +refs/heads/fixes:refs/remotes/origin/fixes" should be run
|
|
|
|
And "git checkout -f -b fixes --track origin/fixes -q" should be run
|
|
|
|
|
|
|
|
Scenario: Same-repo with custom branch name
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2016-08-21 01:00:13 +03:00
|
|
|
:ref => "fixes",
|
|
|
|
:repo => {
|
|
|
|
:name => "jekyll",
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}, :base => {
|
|
|
|
:repo => {
|
|
|
|
:name => "jekyll",
|
|
|
|
:html_url => "https://github.com/mojombo/jekyll",
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I run `hub checkout https://github.com/mojombo/jekyll/pull/77 mycustombranch`
|
|
|
|
Then "git fetch origin +refs/heads/fixes:refs/remotes/origin/fixes" should be run
|
|
|
|
And "git checkout -b mycustombranch --track origin/fixes" should be run
|
2016-10-03 19:39:46 +03:00
|
|
|
|
|
|
|
Scenario: Unavailable fork
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2016-10-03 19:39:46 +03:00
|
|
|
:ref => "fixes",
|
|
|
|
:repo => nil
|
|
|
|
}, :base => {
|
|
|
|
:repo => {
|
|
|
|
:name => "jekyll",
|
|
|
|
:html_url => "https://github.com/mojombo/jekyll",
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I run `hub checkout https://github.com/mojombo/jekyll/pull/77`
|
2016-10-03 19:43:10 +03:00
|
|
|
Then "git fetch origin refs/pull/77/head:pr-77" should be run
|
2016-10-03 19:39:46 +03:00
|
|
|
And "git checkout pr-77" should be run
|
2017-02-04 02:54:44 +03:00
|
|
|
And "pr-77" should merge "refs/pull/77/head" from remote "origin"
|
2016-10-03 20:37:36 +03:00
|
|
|
|
2016-09-12 11:40:51 +03:00
|
|
|
Scenario: Reuse existing remote for head branch
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2016-09-12 11:40:51 +03:00
|
|
|
:ref => "fixes",
|
|
|
|
:repo => {
|
|
|
|
:owner => { :login => "mislav" },
|
|
|
|
:name => "jekyll",
|
|
|
|
:private => false
|
|
|
|
}
|
|
|
|
}, :base => {
|
|
|
|
:repo => {
|
|
|
|
:name => 'jekyll',
|
|
|
|
:html_url => 'https://github.com/mojombo/jekyll',
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
And the "mislav" remote has url "git://github.com/mislav/jekyll.git"
|
|
|
|
When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
|
|
|
|
Then "git fetch mislav +refs/heads/fixes:refs/remotes/mislav/fixes" should be run
|
|
|
|
And "git checkout -f -b fixes --track mislav/fixes -q" should be run
|
|
|
|
|
|
|
|
Scenario: Reuse existing remote and branch
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2016-09-12 11:40:51 +03:00
|
|
|
:ref => "fixes",
|
|
|
|
:repo => {
|
|
|
|
:owner => { :login => "mislav" },
|
|
|
|
:name => "jekyll",
|
|
|
|
:private => false
|
|
|
|
}
|
|
|
|
}, :base => {
|
|
|
|
:repo => {
|
|
|
|
:name => 'jekyll',
|
|
|
|
:html_url => 'https://github.com/mojombo/jekyll',
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
And the "mislav" remote has url "git://github.com/mislav/jekyll.git"
|
|
|
|
And I am on the "fixes" branch
|
|
|
|
When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
|
|
|
|
Then "git fetch mislav +refs/heads/fixes:refs/remotes/mislav/fixes" should be run
|
|
|
|
And "git checkout -f fixes -q" should be run
|
|
|
|
And "git merge --ff-only refs/remotes/mislav/fixes" should be run
|
2017-02-03 10:53:44 +03:00
|
|
|
|
|
|
|
Scenario: Modifiable fork
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2017-02-03 10:53:44 +03:00
|
|
|
:ref => "fixes",
|
|
|
|
:repo => {
|
|
|
|
:owner => { :login => "mislav" },
|
|
|
|
:name => "jekyll",
|
2017-02-04 02:54:44 +03:00
|
|
|
:html_url => "https://github.com/mislav/jekyll.git",
|
2017-02-03 10:53:44 +03:00
|
|
|
:private => false
|
|
|
|
},
|
|
|
|
}, :base => {
|
|
|
|
:repo => {
|
|
|
|
:name => 'jekyll',
|
|
|
|
:html_url => 'https://github.com/mojombo/jekyll',
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}, :maintainer_can_modify => true
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
|
|
|
|
Then "git fetch origin refs/pull/77/head:mislav-fixes" should be run
|
|
|
|
And "git checkout -f mislav-fixes -q" should be run
|
2017-02-04 02:54:44 +03:00
|
|
|
And "mislav-fixes" should merge "refs/heads/fixes" from remote "git@github.com:mislav/jekyll.git"
|
|
|
|
|
|
|
|
Scenario: Modifiable fork with HTTPS
|
|
|
|
Given the GitHub API server:
|
|
|
|
"""
|
|
|
|
get('/repos/mojombo/jekyll/pulls/77') {
|
2017-04-08 23:14:22 +03:00
|
|
|
json :number => 77, :head => {
|
2017-02-04 02:54:44 +03:00
|
|
|
:ref => "fixes",
|
|
|
|
:repo => {
|
|
|
|
:owner => { :login => "mislav" },
|
|
|
|
:name => "jekyll",
|
|
|
|
:html_url => "https://github.com/mislav/jekyll.git",
|
|
|
|
:private => false
|
|
|
|
},
|
|
|
|
}, :base => {
|
|
|
|
:repo => {
|
|
|
|
:name => 'jekyll',
|
|
|
|
:html_url => 'https://github.com/mojombo/jekyll',
|
|
|
|
:owner => { :login => "mojombo" },
|
|
|
|
}
|
|
|
|
}, :maintainer_can_modify => true
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
And HTTPS is preferred
|
|
|
|
When I run `hub checkout -f https://github.com/mojombo/jekyll/pull/77 -q`
|
|
|
|
Then "git fetch origin refs/pull/77/head:mislav-fixes" should be run
|
|
|
|
And "git checkout -f mislav-fixes -q" should be run
|
|
|
|
And "mislav-fixes" should merge "refs/heads/fixes" from remote "https://github.com/mislav/jekyll.git"
|