mirror of
https://github.com/x-motemen/ghq.git
synced 2026-09-10 07:26:27 -04:00
feat(get): add ghq.defaultHost config to resolve the default host.
This commit is contained in:
parent
c71ae6ae4b
commit
c042fa4d99
7
url.go
7
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue