Commit ec54d55d authored by wbond's avatar wbond

More tweaks to ci script

parent b321a9d8
...@@ -67,20 +67,42 @@ print() ...@@ -67,20 +67,42 @@ print()
filenames = [] filenames = []
files_changed = run(['git', 'diff', '--name-status', 'HEAD~1']) commit_offset = 1
for line in files_changed.splitlines():
parts = re.split(r'\s+', line, 1) while not filenames:
if len(parts) != 2: command = ['git', 'diff', '--name-status', 'HEAD~%d' % commit_offset]
raise ValueError('git diff-tree output included a line without status and filename\n\n%s' % files_changed) if commit_offset > 1:
status, filename = parts command.append('HEAD~%d' % (commit_offset - 1))
if not filename.endswith('.json'): files_changed = run(command)
print('Skipping %s since it is not a json file' % filename)
for line in files_changed.splitlines():
parts = re.split(r'\s+', line, 1)
if len(parts) != 2:
print('git diff output included a line without status and filename\n\n%s' % files_changed, file=sys.stderr)
exit(3)
status, filename = parts
if not filename.endswith('.json'):
continue
if not re.match(r'repository/(\w|0-9)\.json$', filename) and filename != 'channel.json':
continue
if status != 'M':
print('Unsure how to test a change that adds or removes a file, aborting', file=sys.stderr)
exit(4)
filenames.append(filename)
# Keep looking back in history for a changeset with repo changes. This is primarily
# a tool to help with initially integrating this script with PRs that already
# existed when it was written
if not filenames:
if commit_offset == 1:
print('Skipping commits that contain no package changes:')
short_commit_hash = run(['git', 'rev-parse', 'HEAD~%d' % (commit_offset - 1)])[0:8]
print(' - %s' % short_commit_hash)
commit_offset += 1
continue continue
if not re.match(r'repository/(\w|0-9)\.json$', filename) and filename != 'channel.json':
print('Skipping %s since is not a json file that specifies packages or repositories' % filename) if commit_offset > 1:
if status != 'M': print()
raise ValueError('Unsure how to test a change that adds or removes a file, aborting')
filenames.append(filename)
def package_name(data): def package_name(data):
if 'name' in data: if 'name' in data:
...@@ -99,8 +121,8 @@ added_repositories = set() ...@@ -99,8 +121,8 @@ added_repositories = set()
removed_repositories = set() removed_repositories = set()
for filename in filenames: for filename in filenames:
old_version = run(['git', 'show', 'HEAD~1:%s' % filename]) old_version = run(['git', 'show', 'HEAD~%d:%s' % (commit_offset, filename)])
new_version = run(['git', 'show', 'HEAD:%s' % filename]) new_version = run(['git', 'show', 'HEAD~%d:%s' % (commit_offset - 1, filename)])
old_json = json.loads(old_version) old_json = json.loads(old_version)
new_json = json.loads(new_version) new_json = json.loads(new_version)
if filename == 'channel.json': if filename == 'channel.json':
...@@ -241,7 +263,7 @@ try: ...@@ -241,7 +263,7 @@ try:
tmpdir = tempfile.mkdtemp() tmpdir = tempfile.mkdtemp()
if not tmpdir: if not tmpdir:
print('Could not create tempdir', file=sys.stderr) print('Could not create tempdir', file=sys.stderr)
exit(3) exit(5)
errors = False errors = False
warnings = False warnings = False
...@@ -376,10 +398,10 @@ try: ...@@ -376,10 +398,10 @@ try:
else: else:
print('Non-VCS package found in primary channel', file=sys.stderr) print('Non-VCS package found in primary channel', file=sys.stderr)
exit(4) exit(6)
if errors: if errors:
exit(5) exit(7)
finally: finally:
if mod_path and os.path.exists(mod_path): if mod_path and os.path.exists(mod_path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment