Skip to content

Commit 4f54a8b

Browse files
committed
Fix version sanitization of epoch
1 parent 69979ca commit 4f54a8b

5 files changed

Lines changed: 9 additions & 1 deletion

File tree

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Changelog
1414
Fix calling ``get_version(root=...)`` in combination with version-file strategy -
1515
relative file version was resolved against ``os.cwd``, not explicitly passed ``root``.
1616

17+
.. change::
18+
:tags: bugfix
19+
20+
Fix epoch versions like ``0!2025.12.3`` were wrongly converted to ``0.2025.12.3``.
21+
1722
.. changelog::
1823
:version: 2.1.0
1924
:released: 10.01.2025

setuptools_git_versioning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
TIMESTAMP_REGEXP = re.compile(r"\{timestamp:?(?P<fmt>[^:}]+)?\}", re.IGNORECASE | re.UNICODE)
3737

3838
# https://github.com/pypa/setuptools/blob/bc39d28bda2a1faee6680ae30e42526b9d775151/setuptools/command/dist_info.py#L108-L131
39-
UNSUPPORTED_SYMBOL_REGEXP = re.compile(r"[^\w\d]+", re.IGNORECASE | re.UNICODE)
39+
UNSUPPORTED_SYMBOL_REGEXP = re.compile(r"[^\w\d!]+", re.IGNORECASE | re.UNICODE)
4040

4141
LOG_FORMAT = "[%(asctime)s] %(levelname)+8s: %(message)s"
4242
# setuptools v60.2.0 changed default logging level to DEBUG: https://github.com/pypa/setuptools/pull/2974

tests/test_integration/test_tag.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def test_tag_missing(repo, create_config, starting_version, version):
108108
[
109109
("1.0.0", "1.0.0"),
110110
("v1.2.3", "1.2.3"),
111+
("1!2.3", "1!2.3"),
111112
("1.2.3dev1", "1.2.3.dev1"),
112113
("1.2.3.dev1", "1.2.3.dev1"),
113114
("1.2.3-dev1", "1.2.3.dev1"),

tests/test_integration/test_version_callback.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def test_version_callback_missing(repo, create_version_py, create_config):
152152
[
153153
("1.0.0", "1.0.0"),
154154
("v1.2.3", "1.2.3"),
155+
("1!2.3", "1!2.3"),
155156
("1.2.3dev1", "1.2.3.dev1"),
156157
("1.2.3.dev1", "1.2.3.dev1"),
157158
("1.2.3-dev1", "1.2.3.dev1"),

tests/test_integration/test_version_file.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def test_version_file_dirty(repo, create_config, add, template, subst):
124124
[
125125
("1.0.0", "1.0.0"),
126126
("v1.2.3", "1.2.3"),
127+
("1!2.3", "1!2.3"),
127128
("1.2.3dev1", "1.2.3.dev1"),
128129
("1.2.3.dev1", "1.2.3.dev1"),
129130
("1.2.3-dev1", "1.2.3.dev1"),

0 commit comments

Comments
 (0)