add ancestry check to validation
Look for the SHA being assigned a new version in the descendants of the previous version to ensure it is merged properly. Change-Id: I82fcb9295bc5eea0c404db898272329dcc515b7b
This commit is contained in:
@@ -99,6 +99,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print('found')
|
print('found')
|
||||||
|
|
||||||
|
prev_version = None
|
||||||
for release in deliverable_info['releases']:
|
for release in deliverable_info['releases']:
|
||||||
for project in release['projects']:
|
for project in release['projects']:
|
||||||
print('%s SHA %s ' % (project['repo'],
|
print('%s SHA %s ' % (project['repo'],
|
||||||
@@ -151,7 +152,30 @@ def main():
|
|||||||
actual_sha,
|
actual_sha,
|
||||||
project['hash']))
|
project['hash']))
|
||||||
else:
|
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:
|
if errors:
|
||||||
print('\n%s errors found' % len(errors))
|
print('\n%s errors found' % len(errors))
|
||||||
|
|||||||
@@ -77,3 +77,13 @@ def sha_for_tag(workdir, repo, version):
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
actual_sha = ''
|
actual_sha = ''
|
||||||
return 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)
|
||||||
|
|||||||
Reference in New Issue
Block a user