提交 9cb62f9f 编写于 作者: M Mislav Marohnić

[pull-request] Avoid crash when branch is pushed to a non-GitHub remote

上级 936f704c
......@@ -141,7 +141,7 @@ func pullRequest(cmd *Command, args *Args) {
trackedBranch, headProject, _ := localRepo.RemoteBranchAndProject(host.User, false)
if headProject == nil {
utils.Check(err)
utils.Check(fmt.Errorf("could not determine project for head branch"))
}
var (
......
......@@ -899,6 +899,24 @@ Feature: hub pull-request
When I successfully run `hub pull-request -m hereyougo`
Then the output should contain exactly "the://url\n"
Scenario: Create pull request to "github" remote when "origin" is non-GitHub
Given the "github" remote has url "git@github.com:sam-hart-swanson/debug.git"
Given the "origin" remote has url "ssh://git@private.server.com/path/to/repo.git"
And I am on the "feat/123-some-branch" branch pushed to "github/feat/123-some-branch"
And an empty file named ".git/refs/remotes/origin/feat/123-some-branch"
Given the GitHub API server:
"""
post('/repos/sam-hart-swanson/debug/pulls') {
assert :base => 'master',
:head => 'sam-hart-swanson:feat/123-some-branch',
:title => 'hereyougo'
status 201
json :html_url => "the://url"
}
"""
When I successfully run `hub pull-request -m hereyougo`
Then the output should contain exactly "the://url\n"
Scenario: Open pull request in web browser
Given I am on the "topic" branch pushed to "origin/topic"
Given the GitHub API server:
......
......@@ -48,6 +48,9 @@ func (b *Branch) PushTarget(owner string, preferUpstream bool) (branch *Branch)
}
for _, remote := range remotesInOrder {
if _, err := remote.Project(); err != nil {
continue
}
if git.HasFile("refs", "remotes", remote.Name, shortName) {
name := fmt.Sprintf("refs/remotes/%s/%s", remote.Name, shortName)
branch = &Branch{b.Repo, name}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册