Merge "add ancestry check to validation"
This commit is contained in:
commit
f9316142a9
@ -99,6 +99,7 @@ def main():
|
||||
else:
|
||||
print('found')
|
||||
|
||||
prev_version = None
|
||||
for release in deliverable_info['releases']:
|
||||
for project in release['projects']:
|
||||
print('%s SHA %s ' % (project['repo'],
|
||||
@ -151,7 +152,30 @@ def main():
|
||||
actual_sha,
|
||||
project['hash']))
|
||||
else:
|
||||
print('NEW')
|
||||
print('NEW ', end='')
|
||||
if not prev_version:
|
||||
print()
|
||||
else:
|
||||
# Check to see if the commit for the new
|
||||
# version is in the ancestors of the
|
||||
# previous release, meaning it is actually
|
||||
# merged into the branch.
|
||||
is_ancestor = gitutils.check_ancestry(
|
||||
workdir,
|
||||
project['repo'],
|
||||
prev_version,
|
||||
project['hash'],
|
||||
)
|
||||
if is_ancestor:
|
||||
print('SHA found in descendants')
|
||||
else:
|
||||
print('SHA NOT FOUND in descendants')
|
||||
errors.append(
|
||||
'%s %s is not a descendant of %s' % (
|
||||
project['repo'], project['hash'],
|
||||
prev_version)
|
||||
)
|
||||
prev_version = release['version']
|
||||
|
||||
if errors:
|
||||
print('\n%s errors found' % len(errors))
|
||||
|
@ -77,3 +77,13 @@ def sha_for_tag(workdir, repo, version):
|
||||
except subprocess.CalledProcessError:
|
||||
actual_sha = ''
|
||||
return actual_sha
|
||||
|
||||
|
||||
def check_ancestry(workdir, repo, old_version, sha):
|
||||
"Check if the SHA is in the ancestry of the previous version."
|
||||
ancestors = subprocess.check_output(
|
||||
['git', 'log', '--oneline', '--ancestry-path',
|
||||
'%s..%s' % (old_version, sha)],
|
||||
cwd=os.path.join(workdir, repo),
|
||||
).strip()
|
||||
return bool(ancestors)
|
||||
|
Loading…
Reference in New Issue
Block a user