Merge "improve SHA detection"

This commit is contained in:
Jenkins 2015-07-22 22:28:37 +00:00 committed by Gerrit Code Review
commit df4f66c880

View File

@ -22,6 +22,7 @@ from __future__ import print_function
import argparse
import glob
import re
import subprocess
import sys
@ -36,13 +37,6 @@ DEFAULT_RELEASE = 'liberty'
CGIT_TEMPLATE = 'http://git.openstack.org/cgit/%s/commit/?id=%s'
COMMON_NAMES = set([
'master',
'HEAD',
'origin/master',
'gerrit/master',
])
def find_modified_deliverable_files():
"Return a list of files modified by the most recent commit."
@ -57,6 +51,11 @@ def find_modified_deliverable_files():
return filenames
def is_a_hash(val):
"Return bool indicating if val looks like a valid hash."
return re.search('^[a-f0-9]{40}$', val, re.I) is not None
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
@ -102,7 +101,7 @@ def main():
project['hash']),
end='')
if project['hash'] in COMMON_NAMES:
if not is_a_hash(project['hash']):
print('NOT A SHA HASH')
num_errors += 1
else: