summaryrefslogtreecommitdiff
path: root/packaging
diff options
context:
space:
mode:
authorMatt Davis <nitzmahone@users.noreply.github.com>2018-07-08 21:45:34 -0700
committerGitHub <noreply@github.com>2018-07-08 21:45:34 -0700
commita2bc0129f0f4b5fad6809b8f9932e70ac710f982 (patch)
treef36b8eeb7dd6874f36f9cb568c5644504b225e55 /packaging
parent0f612d1b76e043fe69965925311f30b0a9389d2c (diff)
downloadansible-a2bc0129f0f4b5fad6809b8f9932e70ac710f982.tar.gz
add .post support to rpm/deb version munger (#42444)
Diffstat (limited to 'packaging')
-rw-r--r--packaging/release/tests/version_helper_test.py3
-rw-r--r--packaging/release/versionhelper/version_helper.py29
2 files changed, 22 insertions, 10 deletions
diff --git a/packaging/release/tests/version_helper_test.py b/packaging/release/tests/version_helper_test.py
index f06e00012f..ff14bd4d64 100644
--- a/packaging/release/tests/version_helper_test.py
+++ b/packaging/release/tests/version_helper_test.py
@@ -9,6 +9,7 @@ from versionhelper.version_helper import AnsibleVersionMunger
@pytest.mark.parametrize('version,revision,codename,output_propname,expected', [
('2.5.0.dev1', None, None, 'raw', '2.5.0.dev1'),
+ ('2.5.0a0.post0', None, None, 'raw', '2.5.0a0.post0'),
('2.5.0', None, None, 'raw', '2.5.0'),
('2.5.0.dev1', None, None, 'major_version', '2.5'),
('2.5.0', None, None, 'major_version', '2.5'),
@@ -17,11 +18,13 @@ from versionhelper.version_helper import AnsibleVersionMunger
('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.dev1', None, None, 'deb_version', '2.5.0~b1~dev1'),
+ ('2.5.0b1.post0', None, None, 'deb_version', '2.5.0~b1~post0'),
('2.5.0', None, None, 'deb_version', '2.5.0'),
('2.5.0.dev1', None, None, 'deb_release', '1'),
('2.5.0b1', 2, None, 'deb_release', '2'),
('2.5.0.dev1', None, None, 'rpm_release', '0.1.dev1'),
('2.5.0a1', None, None, 'rpm_release', '0.101.a1'),
+ ('2.5.0a1.post0', None, None, 'rpm_release', '0.101.a1.post0'),
('2.5.0b1', None, None, 'rpm_release', '0.201.b1'),
('2.5.0rc1', None, None, 'rpm_release', '0.1001.rc1'),
('2.5.0rc1', '0.99', None, 'rpm_release', '0.99.rc1'),
diff --git a/packaging/release/versionhelper/version_helper.py b/packaging/release/versionhelper/version_helper.py
index 018d979a00..fab4dbb3f3 100644
--- a/packaging/release/versionhelper/version_helper.py
+++ b/packaging/release/versionhelper/version_helper.py
@@ -31,21 +31,25 @@ class AnsibleVersionMunger(object):
match = self._parsed_regex_match
- # treat dev as prerelease for now
- if v.is_prerelease or match.group('dev'):
+ # treat dev/post as prerelease for now; treat dev/post as equivalent and disallow together
+ if v.is_prerelease or match.group('dev') or match.group('post'):
+ if match.group('dev') and match.group('post'):
+ raise Exception("dev and post may not currently be used together")
if match.group('pre'):
tag_value = match.group('pre')
tag_type = match.group('pre_l')
if match.group('dev'):
tag_value += ('~%s' % match.group('dev').strip('.'))
+ if match.group('post'):
+ tag_value += ('~%s' % match.group('post').strip('.'))
elif match.group('dev'):
tag_type = "dev"
tag_value = match.group('dev').strip('.')
+ elif match.group('post'):
+ tag_type = "dev"
+ tag_value = match.group('post').strip('.')
else:
raise Exception("unknown prerelease type for version {0}".format(self._raw_version))
-
- elif v.is_postrelease:
- raise Exception("post-release identifiers are not supported")
else:
tag_type = None
tag_value = ''
@@ -66,23 +70,28 @@ class AnsibleVersionMunger(object):
v = self._parsed_version
match = self._parsed_regex_match
- # treat presence of dev as prerelease for now
- if v.is_prerelease or match.group('dev'):
+ # treat presence of dev/post as prerelease for now; treat dev/post the same and disallow together
+ if v.is_prerelease or match.group('dev') or match.group('post'):
+ if match.group('dev') and match.group('post'):
+ raise Exception("dev and post may not currently be used together")
if match.group('pre'):
tag_value = match.group('pre')
tag_type = match.group('pre_l')
tag_ver = match.group('pre_n')
if match.group('dev'):
tag_value += match.group('dev')
+ if match.group('post'):
+ tag_value += match.group('post')
elif match.group('dev'):
tag_type = "dev"
tag_value = match.group('dev')
tag_ver = match.group('dev_n')
+ elif match.group('post'):
+ tag_type = "dev"
+ tag_value = match.group('post')
+ tag_ver = match.group('post_n')
else:
raise Exception("unknown prerelease type for version {0}".format(self._raw_version))
-
- elif v.is_postrelease:
- raise Exception("post-release identifiers are not supported")
else:
tag_type = None
tag_value = ''