Skip to content

Commit

Permalink
Merge pull request #909 from RonnyPfannschmidt/fix-906-parse-paramete…
Browse files Browse the repository at this point in the history
…rs-from-setup

fix #906: ensure tag regex from setup.py is converted to regex
  • Loading branch information
RonnyPfannschmidt authored Sep 20, 2023
2 parents 06958fb + cd5d241 commit 77e79f4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ bugfix
------

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

v8.0.0
======
Expand Down
6 changes: 5 additions & 1 deletion src/setuptools_scm/_integration/setuptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ def version_keyword(
dist_name = read_dist_name_from_setup_cfg()
version_cls = value.pop("version_cls", None)
normalize = value.pop("normalize", True)
tag_regex = _config._check_tag_regex(
value.pop("tag_regex", _config.DEFAULT_TAG_REGEX)
)
final_version = _validate_version_cls(version_cls, normalize)

config = _config.Configuration(
dist_name=dist_name, version_cls=final_version, **value
dist_name=dist_name, version_cls=final_version, tag_regex=tag_regex, **value
)
_assign_version(dist, config)

Expand Down
14 changes: 14 additions & 0 deletions testing/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,17 @@ def test_unicode_in_setup_cfg(tmp_path: Path) -> None:
)
name = setuptools_scm._integration.setuptools.read_dist_name_from_setup_cfg(cfg)
assert name == "configparser"


def test_setuptools_version_keyword_ensures_regex(
wd: WorkDir,
monkeypatch: pytest.MonkeyPatch,
) -> None:
wd.commit_testfile("test")
wd("git tag 1.0")
monkeypatch.chdir(wd.cwd)
from setuptools_scm._integration.setuptools import version_keyword
import setuptools

dist = setuptools.Distribution({"name": "test"})
version_keyword(dist, "use_scm_version", {"tag_regex": "(1.0)"})

0 comments on commit 77e79f4

Please sign in to comment.