Handle legacy version specifiers that would previously raise exceptions.
This commit is contained in:
parent
55905e4681
commit
ec5fc7a5cd
@ -6,7 +6,7 @@ License: MIT
|
||||
|
||||
# Keep the version at zero and increment only release
|
||||
Version: 0
|
||||
Release: 51%{?dist}
|
||||
Release: 52%{?dist}
|
||||
|
||||
# Macro files
|
||||
Source001: macros.pyproject
|
||||
@ -116,6 +116,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
||||
%license LICENSE
|
||||
|
||||
%changelog
|
||||
* Sun Dec 19 2021 Gordon Messmer <gordon.messmer@gmail.com> - 0-52
|
||||
- Handle legacy version specifiers that would previously raise exceptions.
|
||||
|
||||
* Wed Dec 08 2021 Miro Hrončok <mhroncok@redhat.com> - 0-51
|
||||
- Define provisional %%pyproject_build_lib
|
||||
|
||||
|
@ -40,6 +40,9 @@ class RpmVersion():
|
||||
# in public releases
|
||||
# https://www.python.org/dev/peps/pep-0440/#local-version-identifiers
|
||||
|
||||
def is_legacy(self):
|
||||
return isinstance(self.version, str)
|
||||
|
||||
def increment(self):
|
||||
self.version[-1] += 1
|
||||
self.pre = None
|
||||
@ -48,7 +51,7 @@ class RpmVersion():
|
||||
return self
|
||||
|
||||
def __str__(self):
|
||||
if isinstance(self.version, str):
|
||||
if self.is_legacy():
|
||||
return self.version
|
||||
if self.epoch:
|
||||
rpm_epoch = str(self.epoch) + ':'
|
||||
@ -71,6 +74,9 @@ def convert_compatible(name, operator, version_id):
|
||||
if version_id.endswith('.*'):
|
||||
return 'Invalid version'
|
||||
version = RpmVersion(version_id)
|
||||
if version.is_legacy():
|
||||
# LegacyVersions are not supported in this context
|
||||
return 'Invalid version'
|
||||
if len(version.version) == 1:
|
||||
return 'Invalid version'
|
||||
upper_version = RpmVersion(version_id)
|
||||
@ -96,6 +102,9 @@ def convert_not_equal(name, operator, version_id):
|
||||
if version_id.endswith('.*'):
|
||||
version_id = version_id[:-2]
|
||||
version = RpmVersion(version_id)
|
||||
if version.is_legacy():
|
||||
# LegacyVersions are not supported in this context
|
||||
return 'Invalid version'
|
||||
version_gt = RpmVersion(version_id).increment()
|
||||
version_gt_operator = '>='
|
||||
# Prevent dev and pre-releases from satisfying a < requirement
|
||||
@ -126,6 +135,8 @@ def convert_ordered(name, operator, version_id):
|
||||
operator = '<'
|
||||
else:
|
||||
version = RpmVersion(version_id)
|
||||
# For backwards compatibility, fallback to previous behavior with LegacyVersions
|
||||
if not version.is_legacy():
|
||||
# Prevent dev and pre-releases from satisfying a < requirement
|
||||
if operator == '<' and not version.pre and not version.dev and not version.post:
|
||||
version = '{}~~'.format(version)
|
||||
|
Loading…
Reference in New Issue
Block a user