Skip to content

Commit 50f0933

Browse files
fix #213: better error on nonzero dev versions
1 parent 6b444b9 commit 50f0933

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ v4.2.0
1212
* add a version_tuple to write_to templates
1313
* fix #321: add suppport for the ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_${DISTRIBUTION_NAME}`` env var to target the pretend key
1414
* fix #142: clearly list supported scm
15+
* fix #213: better error message for non-zero dev numbers in tags
1516

1617

1718
v4.1.2

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ distance and not clean:
277277
The next version is calculated by adding ``1`` to the last numeric component of
278278
the tag.
279279

280+
280281
For Git projects, the version relies on `git describe <https://git-scm.com/docs/git-describe>`_,
281282
so you will see an additional ``g`` prepended to the ``{revision hash}``.
282283

@@ -507,6 +508,8 @@ Version number construction
507508
:guess-next-dev: Automatically guesses the next development version (default).
508509
Guesses the upcoming release by incrementing the pre-release segment if present,
509510
otherwise by incrementing the micro segment. Then appends :code:`.devN`.
511+
In case the tag ends with ``.dev0`` the version is not bumped
512+
and custom ``.devN`` versions will trigger a error.
510513
:post-release: generates post release versions (adds :code:`.postN`)
511514
:python-simplified-semver: Basic semantic versioning. Guesses the upcoming release
512515
by incrementing the minor segment and setting the micro segment to zero if the

src/setuptools_scm/version.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ def _bump_dev(version):
230230
return
231231

232232
prefix, tail = version.rsplit(".dev", 1)
233-
assert tail == "0", "own dev numbers are unsupported"
233+
if tail != "0":
234+
raise ValueError(
235+
"choosing custom numbers for the `.devX` distance "
236+
"is not supported.\n "
237+
"The {version} can't be bumped\n"
238+
"Please drop the tag or create a new supported one".format(version=version)
239+
)
234240
return prefix
235241

236242

testing/test_version.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ def test_no_guess_version(version, expected_next):
120120
assert computed == expected_next
121121

122122

123+
def test_bump_dev_version_zero():
124+
guess_next_version("1.0.dev0")
125+
126+
127+
def test_bump_dev_version_nonzero_raises():
128+
with pytest.raises(ValueError) as excinfo:
129+
guess_next_version("1.0.dev1")
130+
131+
assert str(excinfo.value) == (
132+
"choosing custom numbers for the `.devX` distance "
133+
"is not supported.\n "
134+
"The 1.0.dev1 can't be bumped\n"
135+
"Please drop the tag or create a new supported one"
136+
)
137+
138+
123139
@pytest.mark.parametrize(
124140
"tag, expected",
125141
[

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ setenv = SETUPTOOLS_SCM_PRETEND_VERSION=2.0
4848
deps=
4949
check-manifest
5050
docutils
51+
pygments
5152
commands=
5253
rst2html.py README.rst {envlogdir}/README.html --strict []
5354
check-manifest

0 commit comments

Comments
 (0)