Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guillaume Martres
aom-rav1e
Commits
2b6fd28d
Commit
2b6fd28d
authored
Oct 17, 2012
by
John Koleszar
Committed by
Gerrit Code Review
Oct 17, 2012
Browse files
Merge "lint-hunks: support operating on arbirary revs" into experimental
parents
07c03b3f
b1cb0077
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/lint-hunks.py
View file @
2b6fd28d
...
...
@@ -21,7 +21,8 @@ SHORT_OPTIONS = "h"
LONG_OPTIONS
=
[
"help"
]
TOPLEVEL_CMD
=
[
"git"
,
"rev-parse"
,
"--show-toplevel"
]
DIFF_CMD
=
[
"git"
,
"diff-index"
,
"-u"
,
"--cached"
,
"HEAD"
,
"--"
]
DIFF_CMD
=
[
"git"
,
"diff"
]
DIFF_INDEX_CMD
=
[
"git"
,
"diff-index"
,
"-u"
,
"--cached"
,
"HEAD"
,
"--"
]
SHOW_CMD
=
[
"git"
,
"show"
]
CPPLINT_FILTERS
=
[
"-readability/casting"
,
"-runtime/int"
]
...
...
@@ -61,7 +62,7 @@ def main(argv=None):
argv
=
sys
.
argv
try
:
try
:
opts
,
_
=
getopt
.
getopt
(
argv
[
1
:],
SHORT_OPTIONS
,
LONG_OPTIONS
)
opts
,
args
=
getopt
.
getopt
(
argv
[
1
:],
SHORT_OPTIONS
,
LONG_OPTIONS
)
except
getopt
.
error
,
msg
:
raise
Usage
(
msg
)
...
...
@@ -71,10 +72,20 @@ def main(argv=None):
print
__doc__
sys
.
exit
(
0
)
if
args
and
len
(
args
)
>
1
:
print
__doc__
sys
.
exit
(
0
)
# Find the fully qualified path to the root of the tree
tl
=
Subprocess
(
TOPLEVEL_CMD
,
stdout
=
subprocess
.
PIPE
)
tl
=
tl
.
communicate
()[
0
].
strip
()
# See if we're working on the index or not.
if
args
:
diff_cmd
=
DIFF_CMD
+
[
args
[
0
]
+
"^!"
]
else
:
diff_cmd
=
DIFF_INDEX_CMD
# Build the command line to execute cpplint
cpplint_cmd
=
[
os
.
path
.
join
(
tl
,
"tools"
,
"cpplint.py"
),
"--filter="
+
","
.
join
(
CPPLINT_FILTERS
),
...
...
@@ -82,7 +93,7 @@ def main(argv=None):
# Get a list of all affected lines
file_affected_line_map
=
{}
p
=
Subprocess
(
DIFF_CMD
,
stdout
=
subprocess
.
PIPE
)
p
=
Subprocess
(
diff_cmd
,
stdout
=
subprocess
.
PIPE
)
stdout
=
p
.
communicate
()[
0
]
for
hunk
in
diff
.
ParseDiffHunks
(
StringIO
.
StringIO
(
stdout
)):
filename
=
hunk
.
right
.
filename
[
2
:]
...
...
Write
Preview
Supports
Markdown
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