cmd/go-contrib-init: don't assume user is in root directory of git checkout
Updates golang/go#17802 Change-Id: I8eeae42f395dee4eedd17114f10bb56536783089 Reviewed-on: https://go-review.googlesource.com/45082 Reviewed-by: Steve Francia <spf@golang.org>
This commit is contained in:
parent
154c88c09d
commit
16c483b02b
|
@ -94,15 +94,16 @@ func checkGitOrigin() {
|
|||
if _, err := exec.LookPath("git"); err != nil {
|
||||
log.Fatalf("You don't appear to have git installed. Do that.")
|
||||
}
|
||||
if _, err := os.Stat(".git"); err != nil {
|
||||
log.Fatalf("You are not currently in a git checkout of https://go.googlesource.com/%s", *repo)
|
||||
}
|
||||
wantRemote := "https://go.googlesource.com/" + *repo
|
||||
remotes, err := exec.Command("git", "remote", "-v").Output()
|
||||
if err != nil {
|
||||
log.Fatalf("Error running git remote -v: %v", cmdErr(err))
|
||||
msg := cmdErr(err)
|
||||
if strings.Contains(msg, "Not a git repository") {
|
||||
log.Fatalf("Your current directory is not in a git checkout of %s", wantRemote)
|
||||
}
|
||||
log.Fatalf("Error running git remote -v: %v", msg)
|
||||
}
|
||||
matches := 0
|
||||
wantRemote := "https://go.googlesource.com/" + *repo
|
||||
for _, line := range strings.Split(string(remotes), "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
if !strings.HasPrefix(line, "origin") {
|
||||
|
|
Loading…
Reference in New Issue