allow dev and prerelease at the same time (#41464)

pull/35713/merge
Matt Davis 7 years ago committed by GitHub
parent a5fd86cf6d
commit 0c92b11335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,23 +8,25 @@ from versionhelper.version_helper import AnsibleVersionMunger
@pytest.mark.parametrize('version,revision,codename,output_propname,expected', [ @pytest.mark.parametrize('version,revision,codename,output_propname,expected', [
('2.5.0dev1', None, None, 'raw', '2.5.0dev1'), ('2.5.0.dev1', None, None, 'raw', '2.5.0.dev1'),
('2.5.0', None, None, 'raw', '2.5.0'), ('2.5.0', None, None, 'raw', '2.5.0'),
('2.5.0dev1', None, None, 'major_version', '2.5'), ('2.5.0.dev1', None, None, 'major_version', '2.5'),
('2.5.0', None, None, 'major_version', '2.5'), ('2.5.0', None, None, 'major_version', '2.5'),
('2.5.0dev1', None, None, 'base_version', '2.5.0'), ('2.5.0.dev1', None, None, 'base_version', '2.5.0'),
('2.5.0', None, None, 'base_version', '2.5.0'), ('2.5.0', None, None, 'base_version', '2.5.0'),
('2.5.0dev1', None, None, 'deb_version', '2.5.0~dev1'), ('2.5.0.dev1', None, None, 'deb_version', '2.5.0~dev1'),
('2.5.0b1', None, None, 'deb_version', '2.5.0~b1'), ('2.5.0b1', None, None, 'deb_version', '2.5.0~b1'),
('2.5.0b1.dev1', None, None, 'deb_version', '2.5.0~b1~dev1'),
('2.5.0', None, None, 'deb_version', '2.5.0'), ('2.5.0', None, None, 'deb_version', '2.5.0'),
('2.5.0dev1', None, None, 'deb_release', '1'), ('2.5.0.dev1', None, None, 'deb_release', '1'),
('2.5.0b1', 2, None, 'deb_release', '2'), ('2.5.0b1', 2, None, 'deb_release', '2'),
('2.5.0dev1', None, None, 'rpm_release', '0.1.dev1'), ('2.5.0.dev1', None, None, 'rpm_release', '0.1.dev1'),
('2.5.0a1', None, None, 'rpm_release', '0.101.a1'), ('2.5.0a1', None, None, 'rpm_release', '0.101.a1'),
('2.5.0b1', None, None, 'rpm_release', '0.201.b1'), ('2.5.0b1', None, None, 'rpm_release', '0.201.b1'),
('2.5.0rc1', None, None, 'rpm_release', '0.1001.rc1'), ('2.5.0rc1', None, None, 'rpm_release', '0.1001.rc1'),
('2.5.0rc1', '0.99', None, 'rpm_release', '0.99.rc1'), ('2.5.0rc1', '0.99', None, 'rpm_release', '0.99.rc1'),
('2.5.0.rc.1', None, None, 'rpm_release', '0.1001.rc.1'), ('2.5.0.rc.1', None, None, 'rpm_release', '0.1001.rc.1'),
('2.5.0.rc1.dev1', None, None, 'rpm_release', '0.1001.rc1.dev1'),
('2.5.0', None, None, 'rpm_release', '1'), ('2.5.0', None, None, 'rpm_release', '1'),
('2.5.0', 2, None, 'rpm_release', '2'), ('2.5.0', 2, None, 'rpm_release', '2'),
('2.5.0', None, None, 'codename', 'UNKNOWN'), ('2.5.0', None, None, 'codename', 'UNKNOWN'),

@ -31,15 +31,16 @@ class AnsibleVersionMunger(object):
match = self._parsed_regex_match match = self._parsed_regex_match
if v.is_prerelease: # treat dev as prerelease for now
if v.is_prerelease or match.group('dev'):
if match.group('pre'): if match.group('pre'):
tag_value = match.group('pre') tag_value = match.group('pre')
tag_type = match.group('pre_l') tag_type = match.group('pre_l')
tag_ver = match.group('pre_n') if match.group('dev'):
tag_value += ('~%s' % match.group('dev').strip('.'))
elif match.group('dev'): elif match.group('dev'):
tag_type = "dev" tag_type = "dev"
tag_value = match.group('dev') tag_value = match.group('dev').strip('.')
tag_ver = match.group('dev_n')
else: else:
raise Exception("unknown prerelease type for version {0}".format(self._raw_version)) raise Exception("unknown prerelease type for version {0}".format(self._raw_version))
@ -48,7 +49,6 @@ class AnsibleVersionMunger(object):
else: else:
tag_type = None tag_type = None
tag_value = '' tag_value = ''
tag_ver = 0
# not a pre/post/dev release, just return base version # not a pre/post/dev release, just return base version
if not tag_type: if not tag_type:
@ -66,11 +66,14 @@ class AnsibleVersionMunger(object):
v = self._parsed_version v = self._parsed_version
match = self._parsed_regex_match match = self._parsed_regex_match
if v.is_prerelease: # treat presence of dev as prerelease for now
if v.is_prerelease or match.group('dev'):
if match.group('pre'): if match.group('pre'):
tag_value = match.group('pre') tag_value = match.group('pre')
tag_type = match.group('pre_l') tag_type = match.group('pre_l')
tag_ver = match.group('pre_n') tag_ver = match.group('pre_n')
if match.group('dev'):
tag_value += match.group('dev')
elif match.group('dev'): elif match.group('dev'):
tag_type = "dev" tag_type = "dev"
tag_value = match.group('dev') tag_value = match.group('dev')

Loading…
Cancel
Save