From 44244a82a0a611b352fa2f6ef7dcace91cbbf1cf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 13 Aug 2015 20:24:49 +0000 Subject: [PATCH] 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 --- openstack_releases/cmds/validate.py | 26 +++++++++++++++++++++++++- openstack_releases/gitutils.py | 10 ++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/openstack_releases/cmds/validate.py b/openstack_releases/cmds/validate.py index deeabc3581..22cada22ad 100755 --- a/openstack_releases/cmds/validate.py +++ b/openstack_releases/cmds/validate.py @@ -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)) diff --git a/openstack_releases/gitutils.py b/openstack_releases/gitutils.py index 72563b0806..12e84a2685 100644 --- a/openstack_releases/gitutils.py +++ b/openstack_releases/gitutils.py @@ -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)