提交 6dc2d794 编写于 作者: M Mislav Marohnić

[checkout] Avoid overriding existing branch merge config

上级 91701809
......@@ -138,8 +138,11 @@ func transformCheckoutArgs(args *Args, pullRequest *github.PullRequest, newBranc
remote = project.GitURL("", "", true)
mergeRef = fmt.Sprintf("refs/heads/%s", pullRequest.Head.Ref)
}
args.After("git", "config", fmt.Sprintf("branch.%s.remote", newBranchName), remote)
args.After("git", "config", fmt.Sprintf("branch.%s.merge", newBranchName), mergeRef)
if mc, err := git.Config(fmt.Sprintf("branch.%s.merge", newBranchName)); err != nil || mc == "" {
args.After("git", "config", fmt.Sprintf("branch.%s.remote", newBranchName), remote)
args.After("git", "config", fmt.Sprintf("branch.%s.merge", newBranchName), mergeRef)
}
}
return
}
......
......@@ -33,6 +33,33 @@ Feature: hub checkout <PULLREQ-URL>
And "git checkout -f fixes -q" should be run
And "fixes" should merge "refs/pull/77/head" from remote "origin"
Scenario: Avoid overriding existing merge configuration
Given the GitHub API server:
"""
get('/repos/mojombo/jekyll/pulls/77') {
json :number => 77, :head => {
:ref => "fixes",
:repo => {
:owner => { :login => "mislav" },
:name => "jekyll",
:private => false
}
}, :base => {
:repo => {
:name => 'jekyll',
:html_url => 'https://github.com/mojombo/jekyll',
:owner => { :login => "mojombo" },
}
}, :maintainer_can_modify => false
}
"""
Given I successfully run `git config branch.fixes.remote ORIG_REMOTE`
Given I successfully run `git config branch.fixes.merge custom/ref/spec`
When I successfully run `hub checkout https://github.com/mojombo/jekyll/pull/77`
Then "git fetch origin refs/pull/77/head:fixes" should be run
And "git checkout fixes" should be run
And "fixes" should merge "custom/ref/spec" from remote "ORIG_REMOTE"
Scenario: Head ref matches default branch
Given the GitHub API server:
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册