Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 9 additions & 2 deletions src/setuptools_scm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
20 changes: 15 additions & 5 deletions testing/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
release_branch_semver_version,
tags_to_versions,
no_guess_dev_version,
guess_next_version,
)


Expand Down Expand Up @@ -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")