diff --git a/url.go b/url.go index 0eef388..aee9753 100644 --- a/url.go +++ b/url.go @@ -139,7 +139,12 @@ func newURL(ref string, ssh, forceMe bool) (*url.URL, error) { } } u.Scheme = "https" - u.Host = "github.com" + host, err := gitconfig.Get("ghq.defaultHost") + if (err != nil && !gitconfig.IsNotFound(err)) || host != "" { + u.Host = host + } else { + u.Host = "github.com" + } if u.Path[0] != '/' { u.Path = "/" + u.Path } diff --git a/url_test.go b/url_test.go index 22207f0..65c81a3 100644 --- a/url_test.go +++ b/url_test.go @@ -66,6 +66,15 @@ completeUser = false`)) url: "peco", expect: "https://github.com/peco/peco", host: "github.com", + }, { + name: "configured default host", + setup: func(t *testing.T) { + t.Cleanup(gitconfig.WithConfig(t, `[ghq] +defaultHost = gitlab.com`)) + }, + url: "gnuwget/wget2", + expect: "https://gitlab.com/gnuwget/wget2", + host: "gitlab.com", }} for _, tc := range testCases {