diff options
author | Russ Cox <rsc@golang.org> | 2009-11-05 08:11:44 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-11-05 08:11:44 -0800 |
commit | e05284877537caaafe6a25340ee48fd3fd2ad272 (patch) | |
tree | 23c582aee82f0264883b96d6a84a2d0db25c6900 /lib/codereview/codereview.py | |
parent | c1f8e3f646c4e042fca9224baf27a0cd94692ace (diff) | |
download | golang-e05284877537caaafe6a25340ee48fd3fd2ad272.tar.gz |
add -l flag to hg gofmt.
don't apply gofmt to non-go files during upload check.
R=r
http://go/go-review/1016048
Diffstat (limited to 'lib/codereview/codereview.py')
-rw-r--r-- | lib/codereview/codereview.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py index 457b18351..0e71a699e 100644 --- a/lib/codereview/codereview.py +++ b/lib/codereview/codereview.py @@ -562,8 +562,8 @@ def RelativePath(path, cwd): # Check that gofmt run on the list of files does not change them def CheckGofmt(ui, repo, files): - f = [f for f in files if f.endswith('.go')] - if not f: + files = [f for f in files if f.endswith('.go')] + if not files: return cwd = os.getcwd() files = [RelativePath(repo.root + '/' + f, cwd) for f in files] @@ -761,7 +761,10 @@ def gofmt(ui, repo, *pats, **opts): cwd = os.getcwd() files = [RelativePath(repo.root + '/' + f, cwd) for f in files] try: - if os.spawnvp(os.P_WAIT, "gofmt", ["gofmt", "-l", "-w"] + files) != 0: + cmd = ["gofmt", "-l"] + if not opts["list"]: + cmd += ["-w"] + if os.spawnvp(os.P_WAIT, "gofmt", cmd + files) != 0: raise util.Abort("gofmt did not exit cleanly") except error.Abort, e: raise @@ -1026,7 +1029,9 @@ cmdtable = { ), "^gofmt": ( gofmt, - [], + [ + ('l', 'list', None, 'list files that would change, but do not edit them'), + ], "FILE ..." ), "^pending|p": ( |