Merge "fix commit_exists() to not rely on commits being on named branches"

This commit is contained in:
Jenkins
2017-09-06 08:16:58 +00:00
committed by Gerrit Code Review

View File

@@ -43,10 +43,19 @@ def find_modified_deliverable_files():
def commit_exists(workdir, repo, ref): def commit_exists(workdir, repo, ref):
"""Return boolean specifying whether the reference exists in the repository. """Return boolean specifying whether the reference exists in the repository.
The commit must exist on a named branch. The commit must have been merged into the repository, but this
check does not enforce any branch membership.
""" """
return bool(branches_containing(workdir, repo, ref)) try:
subprocess.check_output(
['git', 'show', ref],
cwd=os.path.join(workdir, repo),
).decode('utf-8')
except subprocess.CalledProcessError as err:
print('Could not find {}: {}'.format(ref, err))
return False
return True
def tag_exists(repo, ref): def tag_exists(repo, ref):