fix commit_exists() to not rely on commits being on named branches
When we delete stable branches a commit may not appear to be on a named branch, so validation for old releases may fail even though the commit is still in the repository. This change uses 'git show' instead of 'git branch --contains' to separate the tests for existence and branch membership. Change-Id: I58213b29bb37c7c428017204a4bdd5235a5816ca Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
@@ -43,10 +43,19 @@ def find_modified_deliverable_files():
|
||||
def commit_exists(workdir, repo, ref):
|
||||
"""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):
|
||||
|
||||
Reference in New Issue
Block a user