summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Pfannschmidt <ronny.pfannschmidt@redhat.com>2020-12-06 17:12:15 +0100
committerRonny Pfannschmidt <ronny.pfannschmidt@redhat.com>2020-12-06 17:48:36 +0100
commit50f0933809f2b1d46e792a6f7ca872c208dffcdc (patch)
tree4c61a51aa9f6bc9b344c207fa51824f7a8ccc356
parent6b444b930e95d8487c30534d9dab083739e497f8 (diff)
downloadsetuptools-scm-50f0933809f2b1d46e792a6f7ca872c208dffcdc.tar.gz
fix #213: better error on nonzero dev versions
-rw-r--r--CHANGELOG.rst1
-rw-r--r--README.rst3
-rw-r--r--src/setuptools_scm/version.py8
-rw-r--r--testing/test_version.py16
-rw-r--r--tox.ini1
5 files changed, 28 insertions, 1 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index dbce446..c570357 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -12,6 +12,7 @@ v4.2.0
* add a version_tuple to write_to templates
* fix #321: add suppport for the ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_${DISTRIBUTION_NAME}`` env var to target the pretend key
* fix #142: clearly list supported scm
+* fix #213: better error message for non-zero dev numbers in tags
v4.1.2
diff --git a/README.rst b/README.rst
index a826b1f..f9193c1 100644
--- a/README.rst
+++ b/README.rst
@@ -277,6 +277,7 @@ distance and not clean:
The next version is calculated by adding ``1`` to the last numeric component of
the tag.
+
For Git projects, the version relies on `git describe <https://git-scm.com/docs/git-describe>`_,
so you will see an additional ``g`` prepended to the ``{revision hash}``.
@@ -507,6 +508,8 @@ Version number construction
:guess-next-dev: Automatically guesses the next development version (default).
Guesses the upcoming release by incrementing the pre-release segment if present,
otherwise by incrementing the micro segment. Then appends :code:`.devN`.
+ In case the tag ends with ``.dev0`` the version is not bumped
+ and custom ``.devN`` versions will trigger a error.
:post-release: generates post release versions (adds :code:`.postN`)
:python-simplified-semver: Basic semantic versioning. Guesses the upcoming release
by incrementing the minor segment and setting the micro segment to zero if the
diff --git a/src/setuptools_scm/version.py b/src/setuptools_scm/version.py
index 40eadc8..f97dca5 100644
--- a/src/setuptools_scm/version.py
+++ b/src/setuptools_scm/version.py
@@ -230,7 +230,13 @@ def _bump_dev(version):
return
prefix, tail = version.rsplit(".dev", 1)
- assert tail == "0", "own dev numbers are unsupported"
+ if tail != "0":
+ raise ValueError(
+ "choosing custom numbers for the `.devX` distance "
+ "is not supported.\n "
+ "The {version} can't be bumped\n"
+ "Please drop the tag or create a new supported one".format(version=version)
+ )
return prefix
diff --git a/testing/test_version.py b/testing/test_version.py
index 722b8e8..ee13801 100644
--- a/testing/test_version.py
+++ b/testing/test_version.py
@@ -120,6 +120,22 @@ def test_no_guess_version(version, expected_next):
assert computed == expected_next
+def test_bump_dev_version_zero():
+ guess_next_version("1.0.dev0")
+
+
+def test_bump_dev_version_nonzero_raises():
+ with pytest.raises(ValueError) as excinfo:
+ guess_next_version("1.0.dev1")
+
+ assert str(excinfo.value) == (
+ "choosing custom numbers for the `.devX` distance "
+ "is not supported.\n "
+ "The 1.0.dev1 can't be bumped\n"
+ "Please drop the tag or create a new supported one"
+ )
+
+
@pytest.mark.parametrize(
"tag, expected",
[
diff --git a/tox.ini b/tox.ini
index 5f1143e..030dbd4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -48,6 +48,7 @@ setenv = SETUPTOOLS_SCM_PRETEND_VERSION=2.0
deps=
check-manifest
docutils
+ pygments
commands=
rst2html.py README.rst {envlogdir}/README.html --strict []
check-manifest