diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2015-04-28 12:07:28 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2015-04-29 00:04:15 +0000 |
| commit | af3758ca538112730b99a2ebb005eefba171b9a8 (patch) | |
| tree | 4e3c9a0d94c74be035d2399ad7c476f51092e51b | |
| parent | f04a532814986eca2b0b33f88fc783e01ccb9067 (diff) | |
| download | go-x-review-af3758ca538112730b99a2ebb005eefba171b9a8.tar.xz | |
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>
| -rw-r--r-- | git-codereview/gofmt.go | 12 |
1 files changed, 9 insertions, 3 deletions
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 @@ const ( // // 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 @@ func runGofmt(flags int) (files []string, stderrText string) { // 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. |
