Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #906: ensure tag regex from setup.py is converted to regex #909

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
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)"})
Loading