summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaetan Semet <gaetan@xeberon.net>2018-01-05 14:31:03 +0100
committerStephen Finucane <stephenfin@redhat.com>2018-01-05 14:19:47 +0000
commit4c775e7890e90fc2ea77c66020659e52d6a61414 (patch)
tree7be48461caf9090e7f3fcd2ab523a7bb40aa4449
parent4e859e76d38ac0272068171c78dbf67fa13b438d (diff)
downloadpbr-4c775e7890e90fc2ea77c66020659e52d6a61414.tar.gz
Support v<semver> version
Allow protect tag (in gitlab, github) using "v*" regex. Change-Id: I3e6eb1031ae92349c5a9531b143b6470482664e7 Signed-off-by: Gaetan Semet <gaetan@xeberon.net>
-rw-r--r--doc/source/user/features.rst6
-rw-r--r--pbr/tests/test_version.py13
-rw-r--r--pbr/version.py1
-rw-r--r--releasenotes/notes/v_version-457b38c8679c5868.yaml5
4 files changed, 25 insertions, 0 deletions
diff --git a/doc/source/user/features.rst b/doc/source/user/features.rst
index 2a4c25c..fb82255 100644
--- a/doc/source/user/features.rst
+++ b/doc/source/user/features.rst
@@ -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
diff --git a/pbr/tests/test_version.py b/pbr/tests/test_version.py
index 14c8d17..d861d57 100644
--- a/pbr/tests/test_version.py
+++ b/pbr/tests/test_version.py
@@ -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(
diff --git a/pbr/version.py b/pbr/version.py
index 474faf1..5eb217a 100644
--- a/pbr/version.py
+++ b/pbr/version.py
@@ -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('.')
diff --git a/releasenotes/notes/v_version-457b38c8679c5868.yaml b/releasenotes/notes/v_version-457b38c8679c5868.yaml
new file mode 100644
index 0000000..696ba41
--- /dev/null
+++ b/releasenotes/notes/v_version-457b38c8679c5868.yaml
@@ -0,0 +1,5 @@
+---
+features:
+ - |
+ Support version parsing of git tag with the ``v<semver>`` pattern
+ (or ``V<semver>``), in addition to ``<semver>``.