@@ -35,6 +35,9 @@ func main() {
35
35
checkWorkingDir ()
36
36
checkGitOrigin ()
37
37
checkGitCodeReview ()
38
+ fmt .Print ("All good. Happy hacking!\n " +
39
+ "Remember to squash your revised commits and preserve the magic Change-Id lines.\n " +
40
+ "Next steps: https://golang.org/doc/contribute.html#commit_changes\n " )
38
41
}
39
42
40
43
func checkCLA () {
@@ -139,16 +142,25 @@ func checkGitCodeReview() {
139
142
if err != nil {
140
143
log .Printf ("Error running go get golang.org/x/review/git-codereview: %v" , cmdErr (err ))
141
144
}
145
+ log .Printf ("Installed git-codereview (ran `go get golang.org/x/review/git-codereview`)" )
142
146
}
143
- if * dry {
144
- // TODO: check the aliases. For now, just return.
145
- return
146
- }
147
+ missing := false
147
148
for _ , cmd := range []string {"change" , "gofmt" , "mail" , "pending" , "submit" , "sync" } {
148
- err := exec .Command ("git" , "config" , "alias." + cmd , "codereview " + cmd ).Run ()
149
- if err != nil {
150
- log .Fatalf ("Error setting alias.%s: %v" , cmd , cmdErr (err ))
149
+ v , _ := exec .Command ("git" , "config" , "alias." + cmd ).Output ()
150
+ if strings .Contains (string (v ), "codereview" ) {
151
+ continue
152
+ }
153
+ if * dry {
154
+ log .Printf ("Missing alias. Run:\n \t $ git config alias.%s \" codereview %s\" " , cmd , cmd )
155
+ missing = true
156
+ } else {
157
+ err := exec .Command ("git" , "config" , "alias." + cmd , "codereview " + cmd ).Run ()
158
+ if err != nil {
159
+ log .Fatalf ("Error setting alias.%s: %v" , cmd , cmdErr (err ))
160
+ }
151
161
}
152
162
}
153
-
163
+ if missing {
164
+ log .Fatalf ("Missing aliases. (While optional, this tool assumes you use them.)" )
165
+ }
154
166
}
0 commit comments