diff options
author | Ronny Pfannschmidt <ronny.pfannschmidt@redhat.com> | 2020-12-06 17:12:15 +0100 |
---|---|---|
committer | Ronny Pfannschmidt <ronny.pfannschmidt@redhat.com> | 2020-12-06 17:48:36 +0100 |
commit | 50f0933809f2b1d46e792a6f7ca872c208dffcdc (patch) | |
tree | 4c61a51aa9f6bc9b344c207fa51824f7a8ccc356 | |
parent | 6b444b930e95d8487c30534d9dab083739e497f8 (diff) | |
download | setuptools-scm-50f0933809f2b1d46e792a6f7ca872c208dffcdc.tar.gz |
fix #213: better error on nonzero dev versions
-rw-r--r-- | CHANGELOG.rst | 1 | ||||
-rw-r--r-- | README.rst | 3 | ||||
-rw-r--r-- | src/setuptools_scm/version.py | 8 | ||||
-rw-r--r-- | testing/test_version.py | 16 | ||||
-rw-r--r-- | tox.ini | 1 |
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 @@ -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", [ @@ -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 |