mirror of
https://github.com/golang/go
synced 2024-11-18 10:34:51 -07:00
cmd/go-contrib-init: add git alias dry run mode, add success message
Updates golang/go#17802 Change-Id: I2b5473bc0539a760c26889497a301808deb5e5ae Reviewed-on: https://go-review.googlesource.com/45083 Reviewed-by: Steve Francia <spf@golang.org>
This commit is contained in:
parent
16c483b02b
commit
a768197954
@ -35,6 +35,9 @@ func main() {
|
||||
checkWorkingDir()
|
||||
checkGitOrigin()
|
||||
checkGitCodeReview()
|
||||
fmt.Print("All good. Happy hacking!\n" +
|
||||
"Remember to squash your revised commits and preserve the magic Change-Id lines.\n" +
|
||||
"Next steps: https://golang.org/doc/contribute.html#commit_changes\n")
|
||||
}
|
||||
|
||||
func checkCLA() {
|
||||
@ -139,16 +142,25 @@ func checkGitCodeReview() {
|
||||
if err != nil {
|
||||
log.Printf("Error running go get golang.org/x/review/git-codereview: %v", cmdErr(err))
|
||||
}
|
||||
log.Printf("Installed git-codereview (ran `go get golang.org/x/review/git-codereview`)")
|
||||
}
|
||||
if *dry {
|
||||
// TODO: check the aliases. For now, just return.
|
||||
return
|
||||
}
|
||||
missing := false
|
||||
for _, cmd := range []string{"change", "gofmt", "mail", "pending", "submit", "sync"} {
|
||||
err := exec.Command("git", "config", "alias."+cmd, "codereview "+cmd).Run()
|
||||
if err != nil {
|
||||
log.Fatalf("Error setting alias.%s: %v", cmd, cmdErr(err))
|
||||
v, _ := exec.Command("git", "config", "alias."+cmd).Output()
|
||||
if strings.Contains(string(v), "codereview") {
|
||||
continue
|
||||
}
|
||||
if *dry {
|
||||
log.Printf("Missing alias. Run:\n\t$ git config alias.%s \"codereview %s\"", cmd, cmd)
|
||||
missing = true
|
||||
} else {
|
||||
err := exec.Command("git", "config", "alias."+cmd, "codereview "+cmd).Run()
|
||||
if err != nil {
|
||||
log.Fatalf("Error setting alias.%s: %v", cmd, cmdErr(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if missing {
|
||||
log.Fatalf("Missing aliases. (While optional, this tool assumes you use them.)")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user