mirror of
https://github.com/golang/go
synced 2024-11-18 11:24:41 -07:00
cmd/git-contrib-init: support http.cookiefile config for gitcookies
Change-Id: I097905122e1cb7298c31c330731f0fc3c6fc9b59 Reviewed-on: https://go-review.googlesource.com/46235 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
601a54bfa3
commit
cd6e398dae
@ -80,7 +80,27 @@ func checkCLA() {
|
|||||||
" * Run go-contrib-init again.\n")
|
" * Run go-contrib-init again.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func expandUser(s string) string {
|
||||||
|
env := "HOME"
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
env = "USERPROFILE"
|
||||||
|
} else if runtime.GOOS == "plan9" {
|
||||||
|
env = "home"
|
||||||
|
}
|
||||||
|
if home := os.Getenv(env); home != "" {
|
||||||
|
return strings.Replace(s, "~", home, 1)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
func cookiesFile() string {
|
func cookiesFile() string {
|
||||||
|
out, _ := exec.Command("git", "config", "http.cookiefile").Output()
|
||||||
|
if s := strings.TrimSpace(string(out)); s != "" {
|
||||||
|
if strings.Contains(s, "~") {
|
||||||
|
s = expandUser(s)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
return filepath.Join(os.Getenv("USERPROFILE"), ".gitcookies")
|
return filepath.Join(os.Getenv("USERPROFILE"), ".gitcookies")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user