mirror of
https://github.com/golang/go
synced 2024-11-12 04:40:22 -07:00
add -l flag to hg gofmt.
don't apply gofmt to non-go files during upload check. R=r http://go/go-review/1016048
This commit is contained in:
parent
d8e0d9a778
commit
9df7d6ef10
@ -562,8 +562,8 @@ def RelativePath(path, cwd):
|
|||||||
|
|
||||||
# Check that gofmt run on the list of files does not change them
|
# Check that gofmt run on the list of files does not change them
|
||||||
def CheckGofmt(ui, repo, files):
|
def CheckGofmt(ui, repo, files):
|
||||||
f = [f for f in files if f.endswith('.go')]
|
files = [f for f in files if f.endswith('.go')]
|
||||||
if not f:
|
if not files:
|
||||||
return
|
return
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
files = [RelativePath(repo.root + '/' + f, cwd) for f in files]
|
files = [RelativePath(repo.root + '/' + f, cwd) for f in files]
|
||||||
@ -761,7 +761,10 @@ def gofmt(ui, repo, *pats, **opts):
|
|||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
files = [RelativePath(repo.root + '/' + f, cwd) for f in files]
|
files = [RelativePath(repo.root + '/' + f, cwd) for f in files]
|
||||||
try:
|
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")
|
raise util.Abort("gofmt did not exit cleanly")
|
||||||
except error.Abort, e:
|
except error.Abort, e:
|
||||||
raise
|
raise
|
||||||
@ -1026,7 +1029,9 @@ cmdtable = {
|
|||||||
),
|
),
|
||||||
"^gofmt": (
|
"^gofmt": (
|
||||||
gofmt,
|
gofmt,
|
||||||
[],
|
[
|
||||||
|
('l', 'list', None, 'list files that would change, but do not edit them'),
|
||||||
|
],
|
||||||
"FILE ..."
|
"FILE ..."
|
||||||
),
|
),
|
||||||
"^pending|p": (
|
"^pending|p": (
|
||||||
|
Loading…
Reference in New Issue
Block a user