checkstyle: Exit with 1 status if issues are found
Makes the tool return 1 if there is any potential issues. This is needed when using this tool for pre-commit hook in order to abort the commit process. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
3e0c32f992
commit
0b86152a57
1 changed files with 9 additions and 3 deletions
|
@ -541,7 +541,7 @@ def check_style(top_level, commit):
|
||||||
files = [f for f in files if len([p for p in patterns if fnmatch.fnmatch(os.path.basename(f), p)])]
|
files = [f for f in files if len([p for p in patterns if fnmatch.fnmatch(os.path.basename(f), p)])]
|
||||||
if len(files) == 0:
|
if len(files) == 0:
|
||||||
print("Commit doesn't touch source files, skipping")
|
print("Commit doesn't touch source files, skipping")
|
||||||
return
|
return 0
|
||||||
|
|
||||||
issues = 0
|
issues = 0
|
||||||
for f in files:
|
for f in files:
|
||||||
|
@ -554,6 +554,8 @@ def check_style(top_level, commit):
|
||||||
print("%u potential style %s detected, please review" % \
|
print("%u potential style %s detected, please review" % \
|
||||||
(issues, 'issue' if issues == 1 else 'issues'))
|
(issues, 'issue' if issues == 1 else 'issues'))
|
||||||
|
|
||||||
|
return issues
|
||||||
|
|
||||||
|
|
||||||
def extract_revlist(revs):
|
def extract_revlist(revs):
|
||||||
"""Extract a list of commits on which to operate from a revision or revision
|
"""Extract a list of commits on which to operate from a revision or revision
|
||||||
|
@ -632,11 +634,15 @@ def main(argv):
|
||||||
|
|
||||||
revlist = extract_revlist(args.revision_range)
|
revlist = extract_revlist(args.revision_range)
|
||||||
|
|
||||||
|
issues = 0
|
||||||
for commit in revlist:
|
for commit in revlist:
|
||||||
check_style(top_level, commit)
|
issues += check_style(top_level, commit)
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
return 0
|
if issues:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue