зеркало из https://github.com/mislav/hub.git
[checkout] Handle case when PR matches the current branch
This commit is contained in:
Родитель
cd81a7bada
Коммит
9170180900
|
@ -115,8 +115,16 @@ func transformCheckoutArgs(args *Args, pullRequest *github.PullRequest, newBranc
|
|||
}
|
||||
newArgs = append(newArgs, newBranchName)
|
||||
|
||||
b, errB := repo.CurrentBranch()
|
||||
isCurrentBranch := errB == nil && b.ShortName() == newBranchName
|
||||
|
||||
ref := fmt.Sprintf("refs/pull/%d/head", pullRequest.Number)
|
||||
args.Before("git", "fetch", baseRemote.Name, fmt.Sprintf("%s:%s", ref, newBranchName))
|
||||
if isCurrentBranch {
|
||||
args.Before("git", "fetch", baseRemote.Name, ref)
|
||||
args.After("git", "merge", "--ff-only", "FETCH_HEAD")
|
||||
} else {
|
||||
args.Before("git", "fetch", baseRemote.Name, fmt.Sprintf("%s:%s", ref, newBranchName))
|
||||
}
|
||||
|
||||
remote := baseRemote.Name
|
||||
mergeRef := ref
|
||||
|
|
|
@ -251,6 +251,35 @@ Feature: hub checkout <PULLREQ-URL>
|
|||
And "git checkout -f fixes -q" should be run
|
||||
And "fixes" should merge "refs/heads/fixes" from remote "git@github.com:mislav/jekyll.git"
|
||||
|
||||
Scenario: Modifiable fork into current branch
|
||||
Given the GitHub API server:
|
||||
"""
|
||||
get('/repos/mojombo/jekyll/pulls/77') {
|
||||
json :number => 77, :head => {
|
||||
: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 I am on the "fixes" branch
|
||||
And there is a git FETCH_HEAD
|
||||
When I successfully run `hub checkout https://github.com/mojombo/jekyll/pull/77`
|
||||
Then "git fetch origin refs/pull/77/head" should be run
|
||||
And "git checkout fixes" should be run
|
||||
And "git merge --ff-only FETCH_HEAD" should be run
|
||||
And "fixes" should merge "refs/heads/fixes" from remote "git@github.com:mislav/jekyll.git"
|
||||
|
||||
Scenario: Modifiable fork with HTTPS
|
||||
Given the GitHub API server:
|
||||
"""
|
||||
|
|
Загрузка…
Ссылка в новой задаче