From af3758ca538112730b99a2ebb005eefba171b9a8 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 28 Apr 2015 12:07:28 -0700 Subject: 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 --- git-codereview/gofmt.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'git-codereview') 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. -- cgit v1.3