Skip to content

Commit 77e79f4

Browse files
Merge pull request #909 from RonnyPfannschmidt/fix-906-parse-parameters-from-setup
fix #906: ensure tag regex from setup.py is converted to regex
2 parents 06958fb + cd5d241 commit 77e79f4

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ bugfix
66
------
77

88
* update version file template to work on older python versions by using type comments
9+
* ensure tag regex from setup.py is parsed into regex
910

1011
v8.0.0
1112
======

src/setuptools_scm/_integration/setuptools.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ def version_keyword(
9191
dist_name = read_dist_name_from_setup_cfg()
9292
version_cls = value.pop("version_cls", None)
9393
normalize = value.pop("normalize", True)
94+
tag_regex = _config._check_tag_regex(
95+
value.pop("tag_regex", _config.DEFAULT_TAG_REGEX)
96+
)
9497
final_version = _validate_version_cls(version_cls, normalize)
98+
9599
config = _config.Configuration(
96-
dist_name=dist_name, version_cls=final_version, **value
100+
dist_name=dist_name, version_cls=final_version, tag_regex=tag_regex, **value
97101
)
98102
_assign_version(dist, config)
99103

testing/test_integration.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,17 @@ def test_unicode_in_setup_cfg(tmp_path: Path) -> None:
169169
)
170170
name = setuptools_scm._integration.setuptools.read_dist_name_from_setup_cfg(cfg)
171171
assert name == "configparser"
172+
173+
174+
def test_setuptools_version_keyword_ensures_regex(
175+
wd: WorkDir,
176+
monkeypatch: pytest.MonkeyPatch,
177+
) -> None:
178+
wd.commit_testfile("test")
179+
wd("git tag 1.0")
180+
monkeypatch.chdir(wd.cwd)
181+
from setuptools_scm._integration.setuptools import version_keyword
182+
import setuptools
183+
184+
dist = setuptools.Distribution({"name": "test"})
185+
version_keyword(dist, "use_scm_version", {"tag_regex": "(1.0)"})

0 commit comments

Comments
 (0)