Add support for running Checkstyle on a given SHA-1.
Usage e.g.: ./checkstyle.py -s 3aca02ca91816a86febb5ed6e380ec2122adea47 Additionally this CL adds a pre-push script that can be used a git hook to run Checkstyle on 'repo upload' Bug: 25852971 Change-Id: Ia00d48df80b2b024de0899d9590868016c5b7bf0
This commit is contained in:
@@ -110,10 +110,7 @@ def modified_lines(filename, extra_data, commit=None):
|
||||
filename: the file to check.
|
||||
extra_data: is the extra_data returned by modified_files. Additionally, a
|
||||
value of None means that the file was not modified.
|
||||
commit: the complete sha1 (40 chars) of the commit. Note that specifying
|
||||
this value will only work (100%) when commit == last_commit (with
|
||||
respect to the currently checked out revision), otherwise, we could miss
|
||||
some lines.
|
||||
commit: the complete sha1 (40 chars) of the commit.
|
||||
|
||||
Returns: a list of lines that were modified, or None in case all lines are
|
||||
new.
|
||||
@@ -129,7 +126,7 @@ def modified_lines(filename, extra_data, commit=None):
|
||||
|
||||
# Split as bytes, as the output may have some non unicode characters.
|
||||
blame_lines = subprocess.check_output(
|
||||
['git', 'blame', '--porcelain', filename]).split(
|
||||
['git', 'blame', commit, '--porcelain', '--', filename]).split(
|
||||
os.linesep.encode('utf-8'))
|
||||
modified_line_numbers = utils.filter_lines(
|
||||
blame_lines,
|
||||
|
||||
Reference in New Issue
Block a user