summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2012-10-17 14:23:08 -0700
committerJohn Koleszar <jkoleszar@google.com>2012-10-17 14:23:08 -0700
commitb1cb0077f2aa78766a460f82b9792743f767376d (patch)
tree4b547e733eafeef39ecd7c41da1b59d72b0f8be8 /tools
parent9443f05e6b10c2f4de9d21a77df2108dd829529b (diff)
downloadlibvpx-b1cb0077f2aa78766a460f82b9792743f767376d.tar.gz
libvpx-b1cb0077f2aa78766a460f82b9792743f767376d.tar.bz2
libvpx-b1cb0077f2aa78766a460f82b9792743f767376d.zip
lint-hunks: support operating on arbirary revs
Rather than diffing only the index, support checking arbitrary commits. Change-Id: Ia135a487990d8293d1e0799dc062b9f49e020b25
Diffstat (limited to 'tools')
-rwxr-xr-xtools/lint-hunks.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/lint-hunks.py b/tools/lint-hunks.py
index 87c7b0356..c14caecce 100755
--- a/tools/lint-hunks.py
+++ b/tools/lint-hunks.py
@@ -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:]