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
5
url.go
5
url.go
|
|
@ -139,7 +139,12 @@ func newURL(ref string, ssh, forceMe bool) (*url.URL, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
u.Scheme = "https"
|
u.Scheme = "https"
|
||||||
|
host, err := gitconfig.Get("ghq.defaultHost")
|
||||||
|
if (err != nil && !gitconfig.IsNotFound(err)) || host != "" {
|
||||||
|
u.Host = host
|
||||||
|
} else {
|
||||||
u.Host = "github.com"
|
u.Host = "github.com"
|
||||||
|
}
|
||||||
if u.Path[0] != '/' {
|
if u.Path[0] != '/' {
|
||||||
u.Path = "/" + u.Path
|
u.Path = "/" + u.Path
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,15 @@ completeUser = false`))
|
||||||
url: "peco",
|
url: "peco",
|
||||||
expect: "https://github.com/peco/peco",
|
expect: "https://github.com/peco/peco",
|
||||||
host: "github.com",
|
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 {
|
for _, tc := range testCases {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue