git-codereview: require test/run.go to be gofmt'd
See CL 9398 for an instance in which this matters.
Change-Id: If590791e9080b89517536aa80a04cbf2f5fbc3e1
Reviewed-on: https://go-review.googlesource.com/9416
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/git-codereview/gofmt.go b/git-codereview/gofmt.go
index 5c3780e..287bfa8 100644
--- a/git-codereview/gofmt.go
+++ b/git-codereview/gofmt.go
@@ -60,7 +60,7 @@
//
// As a special case for the main repo (but applied everywhere)
// *.go files under a top-level test directory are excluded from the
-// formatting requirement, except those in test/bench/.
+// formatting requirement, except run.go and those in test/bench/.
//
// If gofmtWrite is set (only with gofmtCommand, meaning this is 'git gofmt'),
// runGofmt replaces the original files with their formatted equivalents.
@@ -341,8 +341,14 @@
// for gofmt'dness by the pre-commit hook.
// The file name is relative to the repo root.
func gofmtRequired(file string) bool {
- return strings.HasSuffix(file, ".go") &&
- !(strings.HasPrefix(file, "test/") && !strings.HasPrefix(file, "test/bench/"))
+ // TODO: Consider putting this policy into codereview.cfg.
+ if !strings.HasSuffix(file, ".go") {
+ return false
+ }
+ if !strings.HasPrefix(file, "test/") {
+ return true
+ }
+ return strings.HasPrefix(file, "test/bench/") || file == "test/run.go"
}
// stringMap returns a map m such that m[s] == true if s was in the original list.