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

Merge branch 'localhost'

......@@ -13,7 +13,7 @@ Feature: OAuth authentication
assert_basic_auth 'mislav', 'kitty'
assert :scopes => ['repo'],
:note => "hub for #{machine_id}",
:note_url => 'http://hub.github.com/'
:note_url => 'https://hub.github.com/'
status 201
json :token => 'OTOKEN'
}
......@@ -378,7 +378,7 @@ Feature: OAuth authentication
auth = Rack::Auth::Basic::Request.new(env)
halt 401 unless auth.credentials == %w[mislav kitty]
status 201
json :token => 'OTOKEN', :note_url => 'http://hub.github.com/'
json :token => 'OTOKEN', :note_url => 'https://hub.github.com/'
}
get('/api/v3/user', :host_name => 'git.my.org') {
json :login => 'mislav'
......
......@@ -15,9 +15,8 @@ import (
)
const (
GitHubHost string = "github.com"
GitHubApiHost string = "api.github.com"
OAuthAppURL string = "http://hub.github.com/"
GitHubHost string = "github.com"
OAuthAppURL string = "https://hub.github.com/"
)
var UserAgent = "Hub " + version.Version
......@@ -893,7 +892,7 @@ func (client *Client) apiClient() *simpleClient {
unixSocket := os.ExpandEnv(client.Host.UnixSocket)
httpClient := newHttpClient(os.Getenv("HUB_TEST_HOST"), os.Getenv("HUB_VERBOSE") != "", unixSocket)
apiRoot := client.absolute(normalizeHost(client.Host.Host))
if client.Host != nil && client.Host.Host != GitHubHost {
if !strings.HasPrefix(apiRoot.Host, "api.github.") {
apiRoot.Path = "/api/v3/"
}
......@@ -912,16 +911,15 @@ func (client *Client) absolute(host string) *url.URL {
}
func normalizeHost(host string) string {
host = strings.ToLower(host)
if host == "" {
host = GitHubHost
}
if host == GitHubHost {
host = GitHubApiHost
return GitHubHost
} else if strings.EqualFold(host, GitHubHost) {
return "api.github.com"
} else if strings.EqualFold(host, "github.localhost") {
return "api.github.localhost"
} else {
return strings.ToLower(host)
}
return host
}
func checkStatus(expectedStatus int, action string, response *simpleResponse, err error) error {
......
......@@ -40,7 +40,7 @@ func knownGitHubHosts() []string {
hosts := []string{}
defaultHost := DefaultGitHubHost()
hosts = append(hosts, defaultHost)
hosts = append(hosts, "ssh."+GitHubHost)
hosts = append(hosts, "ssh.github.com")
ghHosts, _ := git.ConfigAll("hub.host")
for _, ghHost := range ghHosts {
......
......@@ -154,7 +154,7 @@ func newProject(owner, name, host, protocol string) *Project {
host = DefaultGitHubHost()
}
if host == "ssh.github.com" {
host = "github.com"
host = GitHubHost
}
if protocol != "http" && protocol != "https" {
......
......@@ -96,6 +96,15 @@ func TestProject_NewProjectFromURL(t *testing.T) {
assert.Equal(t, "github.com", p.Host)
assert.Equal(t, "http", p.Protocol)
u, _ = url.Parse("ssh://ssh.github.com/octokit/go-octokit.git")
p, err = NewProjectFromURL(u)
assert.Equal(t, nil, err)
assert.Equal(t, "go-octokit", p.Name)
assert.Equal(t, "octokit", p.Owner)
assert.Equal(t, "github.com", p.Host)
assert.Equal(t, "http", p.Protocol)
u, _ = url.Parse("git://github.com/octokit/go-octokit.git")
p, err = NewProjectFromURL(u)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册