Commit 4c775e78 authored by Gaetan Semet's avatar Gaetan Semet Committed by Stephen Finucane

Support v<semver> version

Allow protect tag (in gitlab, github) using "v*" regex.

Change-Id: I3e6eb1031ae92349c5a9531b143b6470482664e7
Signed-off-by: 's avatarGaetan Semet <gaetan@xeberon.net>
parent 4e859e76
......@@ -17,6 +17,12 @@ If the currently checked out revision is not tagged, then we take the
last tagged version number and increment it to get a minimum target
version.
.. note::
``pbr`` support bare version tag (ex: ``0.1.0``) and version prefixed with
``v`` or ``V`` (ex: ``v0.1.0``)
We then walk git history back to the last release. Within each commit we look
for a Sem-Ver: pseudo header, and if found parse it looking for keywords.
Unknown symbols are not an error (so that folk can't wedge pbr or break their
......
......@@ -84,6 +84,19 @@ class TestSemanticVersion(base.BaseTestCase):
lambda: from_pip_string('1.2.3.post5.dev6'),
matchers.raises(ValueError))
def test_from_pip_string_v_version(self):
parsed = from_pip_string('v1.2.3')
expected = version.SemanticVersion(1, 2, 3)
self.expectThat(expected, matchers.Equals(parsed))
expected = version.SemanticVersion(1, 2, 3, 'a', 5, dev_count=6)
parsed = from_pip_string('V1.2.3.0a4.post6')
self.expectThat(expected, matchers.Equals(parsed))
self.expectThat(
lambda: from_pip_string('x1.2.3'),
matchers.raises(ValueError))
def test_from_pip_string_legacy_nonzero_lead_in(self):
# reported in bug 1361251
expected = version.SemanticVersion(
......
......@@ -149,6 +149,7 @@ class SemanticVersion(object):
@classmethod
def _from_pip_string_unsafe(klass, version_string):
# Versions need to start numerically, ignore if not
version_string = version_string.lstrip('vV')
if not version_string[:1].isdigit():
raise ValueError("Invalid version %r" % version_string)
input_components = version_string.split('.')
......
---
features:
- |
Support version parsing of git tag with the ``v<semver>`` pattern
(or ``V<semver>``), in addition to ``<semver>``.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment