Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
49bff2da
Commit
49bff2da
authored
Oct 06, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codereview: disallow submit of *.[chys] files indented with spaces
R=r CC=golang-dev
https://golang.org/cl/2383041
parent
4138fdd8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
codereview.py
lib/codereview/codereview.py
+34
-4
No files found.
lib/codereview/codereview.py
View file @
49bff2da
...
@@ -223,7 +223,7 @@ class CL(object):
...
@@ -223,7 +223,7 @@ class CL(object):
if
not
self
.
files
:
if
not
self
.
files
:
ui
.
warn
(
"no files in change list
\n
"
)
ui
.
warn
(
"no files in change list
\n
"
)
if
ui
.
configbool
(
"codereview"
,
"force_gofmt"
,
True
)
and
gofmt
:
if
ui
.
configbool
(
"codereview"
,
"force_gofmt"
,
True
)
and
gofmt
:
Check
Gofm
t
(
ui
,
repo
,
self
.
files
,
just_warn
=
gofmt_just_warn
)
Check
Forma
t
(
ui
,
repo
,
self
.
files
,
just_warn
=
gofmt_just_warn
)
set_status
(
"uploading CL metadata + diffs"
)
set_status
(
"uploading CL metadata + diffs"
)
os
.
chdir
(
repo
.
root
)
os
.
chdir
(
repo
.
root
)
form_fields
=
[
form_fields
=
[
...
@@ -732,9 +732,13 @@ def RelativePath(path, cwd):
...
@@ -732,9 +732,13 @@ def RelativePath(path, cwd):
return
path
[
n
+
1
:]
return
path
[
n
+
1
:]
return
path
return
path
# Check that gofmt run on the list of files does not change them
def
CheckFormat
(
ui
,
repo
,
files
,
just_warn
=
False
):
def
CheckGofmt
(
ui
,
repo
,
files
,
just_warn
=
False
):
set_status
(
"running gofmt"
)
set_status
(
"running gofmt"
)
CheckGofmt
(
ui
,
repo
,
files
,
just_warn
)
CheckTabfmt
(
ui
,
repo
,
files
,
just_warn
)
# Check that gofmt run on the list of files does not change them
def
CheckGofmt
(
ui
,
repo
,
files
,
just_warn
):
files
=
[
f
for
f
in
files
if
(
f
.
startswith
(
'src/'
)
or
f
.
startswith
(
'test/bench/'
))
and
f
.
endswith
(
'.go'
)]
files
=
[
f
for
f
in
files
if
(
f
.
startswith
(
'src/'
)
or
f
.
startswith
(
'test/bench/'
))
and
f
.
endswith
(
'.go'
)]
if
not
files
:
if
not
files
:
return
return
...
@@ -763,6 +767,32 @@ def CheckGofmt(ui, repo, files, just_warn=False):
...
@@ -763,6 +767,32 @@ def CheckGofmt(ui, repo, files, just_warn=False):
raise
util
.
Abort
(
msg
)
raise
util
.
Abort
(
msg
)
return
return
# Check that *.[chys] files indent using tabs.
def
CheckTabfmt
(
ui
,
repo
,
files
,
just_warn
):
files
=
[
f
for
f
in
files
if
f
.
startswith
(
'src/'
)
and
re
.
search
(
r"\.[chys]$"
,
f
)]
if
not
files
:
return
cwd
=
os
.
getcwd
()
files
=
[
RelativePath
(
repo
.
root
+
'/'
+
f
,
cwd
)
for
f
in
files
]
files
=
[
f
for
f
in
files
if
os
.
access
(
f
,
0
)]
badfiles
=
[]
for
f
in
files
:
try
:
for
line
in
open
(
f
,
'r'
):
if
line
.
startswith
(
' '
):
badfiles
.
append
(
f
)
break
except
:
# ignore cannot open file, etc.
pass
if
len
(
badfiles
)
>
0
:
msg
=
"these files use spaces for indentation (use tabs instead):
\n\t
"
+
"
\n\t
"
.
join
(
badfiles
)
if
just_warn
:
ui
.
warn
(
"warning: "
+
msg
+
"
\n
"
)
else
:
raise
util
.
Abort
(
msg
)
return
#######################################################################
#######################################################################
# Mercurial commands
# Mercurial commands
...
@@ -1159,7 +1189,7 @@ def submit(ui, repo, *pats, **opts):
...
@@ -1159,7 +1189,7 @@ def submit(ui, repo, *pats, **opts):
# check gofmt for real; allowed upload to warn in order to save CL.
# check gofmt for real; allowed upload to warn in order to save CL.
cl
.
Flush
(
ui
,
repo
)
cl
.
Flush
(
ui
,
repo
)
Check
Gofm
t
(
ui
,
repo
,
cl
.
files
)
Check
Forma
t
(
ui
,
repo
,
cl
.
files
)
about
+=
"
%
s
%
s
\n
"
%
(
server_url_base
,
cl
.
name
)
about
+=
"
%
s
%
s
\n
"
%
(
server_url_base
,
cl
.
name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment