提交 f5a140f0 编写于 作者: J Jingwen Owen Ou

Merge pull request #691 from github/username_case_insensitive_in_remote_url

Treat remote URL user name case insensitive when creating PR
......@@ -513,6 +513,22 @@ 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 from branch on the personal fork case sensitive
Given the "origin" remote has url "git://github.com/github/coral.git"
And the "doge" remote has url "git://github.com/Mislav/coral.git"
And I am on the "feature" branch pushed to "doge/feature"
Given the GitHub API server:
"""
post('/repos/github/coral/pulls') {
assert :base => 'master',
:head => 'Mislav:feature',
:title => 'hereyougo'
json :html_url => "the://url"
}
"""
When I successfully run `hub pull-request -m hereyougo`
Then the output should contain exactly "the://url\n"
Scenario: Create pull request from branch on the personal fork
Given the "origin" remote has url "git://github.com/github/coral.git"
And the "doge" remote has url "git://github.com/mislav/coral.git"
......
......@@ -2,6 +2,7 @@ package github
import (
"fmt"
"strings"
"github.com/github/hub/git"
)
......@@ -55,7 +56,7 @@ func (r *GitHubRepo) remotesForPublish(owner string) (remotes []Remote) {
if owner != "" {
for _, remote := range r.remotes {
p, e := remote.Project()
if e == nil && p.Owner == owner {
if e == nil && strings.ToLower(p.Owner) == owner {
remotesMap[remote.Name] = remote
}
}
......
package github
import (
"net/url"
"testing"
"github.com/bmizerany/assert"
......@@ -16,3 +17,19 @@ func TestGitHubRepo_OriginRemote(t *testing.T) {
assert.Equal(t, "origin", gitRemote.Name)
assert.Equal(t, repo.Remote, gitRemote.URL.String())
}
func TestGitHubRepo_remotesForPublish(t *testing.T) {
url, _ := url.Parse("ssh://git@github.com/Owner/repo.git")
remotes := []Remote{
{
Name: "Owner",
URL: url,
},
}
repo := GitHubRepo{remotes}
remotesForPublish := repo.remotesForPublish("owner")
assert.Equal(t, 1, len(remotesForPublish))
assert.Equal(t, "Owner", remotesForPublish[0].Name)
assert.Equal(t, url.String(), remotesForPublish[0].URL.String())
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册