Fix hacking.py git checks to propagate errors
Now when N801 or N802 is hit tools/hacking.py will return -1. Fix bug 1039697 Change-Id: I9f6950a4396ae82861e5de0e4f3ba8b482c4fdf8
This commit is contained in:
@@ -436,7 +436,7 @@ def once_git_check_commit_title():
|
|||||||
"""
|
"""
|
||||||
#Get title of most recent commit
|
#Get title of most recent commit
|
||||||
|
|
||||||
subp = subprocess.Popen(['git', 'log', '--pretty=%s', '-1'],
|
subp = subprocess.Popen(['git', 'log', '--no-merges', '--pretty=%s', '-1'],
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
title = subp.communicate()[0]
|
title = subp.communicate()[0]
|
||||||
if subp.returncode:
|
if subp.returncode:
|
||||||
@@ -450,20 +450,24 @@ def once_git_check_commit_title():
|
|||||||
'([Bb]lue[Pp]rint|[Bb][Pp])[\s\#:]*([A-Za-z0-9\\-]+)')
|
'([Bb]lue[Pp]rint|[Bb][Pp])[\s\#:]*([A-Za-z0-9\\-]+)')
|
||||||
GIT_REGEX = re.compile(git_keywords)
|
GIT_REGEX = re.compile(git_keywords)
|
||||||
|
|
||||||
|
error = False
|
||||||
#NOTE(jogo) if match regex but over 3 words, acceptable title
|
#NOTE(jogo) if match regex but over 3 words, acceptable title
|
||||||
if GIT_REGEX.search(title) is not None and len(title.split()) <= 3:
|
if GIT_REGEX.search(title) is not None and len(title.split()) <= 3:
|
||||||
print ("N801: git commit title ('%s') should provide an accurate "
|
print ("N801: git commit title ('%s') should provide an accurate "
|
||||||
"description of the change, not just a reference to a bug "
|
"description of the change, not just a reference to a bug "
|
||||||
"or blueprint" % title.strip())
|
"or blueprint" % title.strip())
|
||||||
|
error = True
|
||||||
if len(title.decode('utf-8')) > 72:
|
if len(title.decode('utf-8')) > 72:
|
||||||
print ("N802: git commit title ('%s') should be under 50 chars"
|
print ("N802: git commit title ('%s') should be under 50 chars"
|
||||||
% title.strip())
|
% title.strip())
|
||||||
|
error = True
|
||||||
|
return error
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#include nova path
|
#include nova path
|
||||||
sys.path.append(os.getcwd())
|
sys.path.append(os.getcwd())
|
||||||
#Run once tests (not per line)
|
#Run once tests (not per line)
|
||||||
once_git_check_commit_title()
|
once_error = once_git_check_commit_title()
|
||||||
#NOVA error codes start with an N
|
#NOVA error codes start with an N
|
||||||
pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
|
pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
|
||||||
add_nova()
|
add_nova()
|
||||||
@@ -473,6 +477,7 @@ if __name__ == "__main__":
|
|||||||
pep8.input_dir = input_dir
|
pep8.input_dir = input_dir
|
||||||
try:
|
try:
|
||||||
pep8._main()
|
pep8._main()
|
||||||
|
sys.exit(once_error)
|
||||||
finally:
|
finally:
|
||||||
if len(_missingImport) > 0:
|
if len(_missingImport) > 0:
|
||||||
print >> sys.stderr, ("%i imports missing in this test environment"
|
print >> sys.stderr, ("%i imports missing in this test environment"
|
||||||
|
Reference in New Issue
Block a user