summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2020-11-29 22:02:46 +0100
committerGitHub <noreply@github.com>2020-11-29 22:02:46 +0100
commit1cb4c5a43fc39a5098491d03dd5520121250e56d (patch)
tree57ac9fcb586d36387ce826a59438e0ba90b030b9
parent57c3590fa632f10c7855edc64fbf4c9c029c0d08 (diff)
parentef36e47111a8ed9d9693107e6a9d5db87592a794 (diff)
downloadsetuptools-scm-1cb4c5a43fc39a5098491d03dd5520121250e56d.tar.gz
Merge pull request #496 from RonnyPfannschmidt/fix-471-better-error-on-broken-bump
fix #471: better error when a simplicistic version bump fails
-rw-r--r--CHANGELOG.rst2
-rw-r--r--src/setuptools_scm/version.py11
-rw-r--r--testing/test_version.py20
3 files changed, 25 insertions, 8 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 0d7a1c3..c376a55 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,7 +1,7 @@
v4.2.0
======
-
+* fix #471: better error for version bump failing on complex but accepted tag
* fix #479: raise indicative error when tags carry non-parsable information
* Add `no-guess-dev` which does no next version guessing, just adds `.post1.devN` in
case there are new commits after the tag
diff --git a/src/setuptools_scm/version.py b/src/setuptools_scm/version.py
index c58be7e..40eadc8 100644
--- a/src/setuptools_scm/version.py
+++ b/src/setuptools_scm/version.py
@@ -235,8 +235,15 @@ def _bump_dev(version):
def _bump_regex(version):
- prefix, tail = re.match(r"(.*?)(\d+)$", version).groups()
- return "%s%d" % (prefix, int(tail) + 1)
+ match = re.match(r"(.*?)(\d+)$", version)
+ if match is None:
+ raise ValueError(
+ "{version} does not end with a number to bump, "
+ "please correct or use a custom version scheme".format(version=version)
+ )
+ else:
+ prefix, tail = match.groups()
+ return "%s%d" % (prefix, int(tail) + 1)
def guess_next_dev_version(version):
diff --git a/testing/test_version.py b/testing/test_version.py
index 38c98bf..722b8e8 100644
--- a/testing/test_version.py
+++ b/testing/test_version.py
@@ -6,6 +6,7 @@ from setuptools_scm.version import (
release_branch_semver_version,
tags_to_versions,
no_guess_dev_version,
+ guess_next_version,
)
@@ -128,19 +129,28 @@ def test_no_guess_version(version, expected_next):
],
)
def test_tag_regex1(tag, expected):
- config = Configuration()
if "+" in tag:
# pytest bug wrt cardinality
with pytest.warns(UserWarning):
- result = meta(tag, config=config)
+ result = meta(tag, config=c)
else:
- result = meta(tag, config=config)
+ result = meta(tag, config=c)
assert result.tag.public == expected
@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/286")
def test_tags_to_versions():
- config = Configuration()
- versions = tags_to_versions(["1.0", "2.0", "3.0"], config=config)
+ versions = tags_to_versions(["1.0", "2.0", "3.0"], config=c)
assert isinstance(versions, list) # enable subscription
+
+
+@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/471")
+def test_version_bump_bad():
+ with pytest.raises(
+ ValueError,
+ match=".*does not end with a number to bump, "
+ "please correct or use a custom version scheme",
+ ):
+
+ guess_next_version(tag_version="2.0.0-alpha.5-PMC")