protect against repos where we can't get project name

Some of the older released versions of projects don't work when we run
'python setup.py --name' (disk-image-builder was the main one I
noticed). This patch protects against those exceptions, and reports them
as warnings if the release is already tagged and errors if it is a new
release.

Change-Id: Iaa47e7ea2a52efee200e8c710c3660a7893b5147
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2017-05-31 13:00:04 -04:00
parent e15218ba1e
commit c0b6e33b49

View File

@ -341,35 +341,48 @@ def validate_releases(deliverable_info, zuul_layout,
# remotely. # remotely.
gitutils.clone_repo(workdir, project['repo'], project['hash']) gitutils.clone_repo(workdir, project['repo'], project['hash'])
version_exists = gitutils.tag_exists(
project['repo'], release['version'],
)
# Check that the sdist name and tarball-base name match. # Check that the sdist name and tarball-base name match.
if link_mode == 'tarball': if link_mode == 'tarball':
sdist = pythonutils.get_sdist_name(workdir, try:
project['repo']) sdist = pythonutils.get_sdist_name(workdir,
if sdist is not None: project['repo'])
expected = project.get( except Exception as err:
'tarball-base', msg = 'Could not get the name of {} for version {}: {}'.format(
os.path.basename(project['repo']), project['repo'], release['version'], err)
) if version_exists:
if sdist != expected: # If there was a problem with an existing
if 'tarball-base' in project: # release, treat it as a warning so we
action = 'is set to' # don't prevent new releases.
else: mk_warning(msg)
action = 'defaults to' else:
mk_error( mk_error(msg)
('tarball-base for %s %s %s %r ' else:
'but the sdist name is actually %r. ' + if sdist is not None:
_PLEASE) expected = project.get(
% (project['repo'], release['version'], 'tarball-base',
action, expected, sdist)) os.path.basename(project['repo']),
)
if sdist != expected:
if 'tarball-base' in project:
action = 'is set to'
else:
action = 'defaults to'
mk_error(
('tarball-base for %s %s %s %r '
'but the sdist name is actually %r. ' +
_PLEASE)
% (project['repo'], release['version'],
action, expected, sdist))
# Report if the version has already been # Report if the version has already been
# tagged. We expect it to not exist, but neither # tagged. We expect it to not exist, but neither
# case is an error because sometimes we want to # case is an error because sometimes we want to
# import history and sometimes we want to make new # import history and sometimes we want to make new
# releases. # releases.
version_exists = gitutils.tag_exists(
project['repo'], release['version'],
)
if version_exists: if version_exists:
actual_sha = gitutils.sha_for_tag( actual_sha = gitutils.sha_for_tag(
workdir, workdir,