fix tag detection

Use a separate URL for testing a tag from testing a SHA, since sometimes
the latter does not work for tags.

Change-Id: I01e71df99b0ab81f171f9e69e5190164e20f5106
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2016-08-16 12:11:02 -04:00
parent 0289d784a2
commit 1227800a37
2 changed files with 23 additions and 6 deletions

View File

@ -243,7 +243,7 @@ def main():
# import history and sometimes we want to make new
# releases.
print('version %s ' % release['version'], end='')
version_exists = gitutils.commit_exists(
version_exists = gitutils.tag_exists(
project['repo'], release['version'],
)
gitutils.clone_repo(workdir, project['repo'])
@ -254,9 +254,9 @@ def main():
release['version'],
)
if actual_sha == project['hash']:
print('found and matches SHA')
print('found and SHAs match, ')
else:
print('found DIFFERENT %r' % actual_sha)
print('found DIFFERENT %r, ' % actual_sha)
errors.append(
('Version %s in %s is on '
'commit %s instead of %s') %
@ -265,7 +265,7 @@ def main():
actual_sha,
project['hash']))
else:
print('NEW ', end='')
print('NEW VERSION, ', end='')
new_releases[release['version']] = release
if not prev_version:
print()

View File

@ -22,7 +22,8 @@ import requests
from requests.packages import urllib3
urllib3.disable_warnings()
CGIT_TEMPLATE = 'http://git.openstack.org/cgit/%s/commit/?id=%s'
CGIT_SHA_TEMPLATE = 'http://git.openstack.org/cgit/%s/commit/?id=%s'
CGIT_TAG_TEMPLATE = 'http://git.openstack.org/cgit/%s/tag/?h=%s'
def find_modified_deliverable_files():
@ -46,7 +47,23 @@ def commit_exists(repo, ref):
someone to fool the check.
"""
url = CGIT_TEMPLATE % (repo, ref)
url = CGIT_SHA_TEMPLATE % (repo, ref)
response = requests.get(url)
missing_commit = (
(response.status_code // 100 != 2) or 'Bad object id' in response.text
)
return not missing_commit
def tag_exists(repo, ref):
"""Return boolean specifying whether the reference exists in the repository.
Uses a cgit query instead of looking locally to avoid cloning a
repository or having Depends-On settings in a commit message allow
someone to fool the check.
"""
url = CGIT_TAG_TEMPLATE % (repo, ref)
response = requests.get(url)
missing_commit = (
(response.status_code // 100 != 2) or 'Bad object id' in response.text