diff options
author | Diego Elio Pettenò <flameeyes@flameeyes.com> | 2020-03-25 14:37:46 +0000 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@flameeyes.com> | 2020-03-25 14:39:32 +0000 |
commit | ad80a3dd2174671d49ef4dd3b431f381d6b0219c (patch) | |
tree | cc69d0c050e7d6119a20f5165cc08b0404995e7d | |
parent | c3cc24c64b78b2c524a9a3f369f2d3c2b1f8533d (diff) | |
download | setuptools-scm-ad80a3dd2174671d49ef4dd3b431f381d6b0219c.tar.gz |
Extract version correctly from tags with a single digit.
This makes sure that even if there's only a single group of digits in the
version, it's correctly extracted, and any suffix ignored.
Also add tests for those particular cases to avoid regressions.
See Issue #411 for debugging details.
-rw-r--r-- | src/setuptools_scm/config.py | 2 | ||||
-rw-r--r-- | testing/test_config.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/setuptools_scm/config.py b/src/setuptools_scm/config.py index 139512d..b452557 100644 --- a/src/setuptools_scm/config.py +++ b/src/setuptools_scm/config.py @@ -6,7 +6,7 @@ import warnings from .utils import trace -DEFAULT_TAG_REGEX = r"^(?:[\w-]+-)?(?P<version>[vV]?\d+(?:\.\d+){0,2}[^\+]+)(?:\+.*)?$" +DEFAULT_TAG_REGEX = r"^(?:[\w-]+-)?(?P<version>[vV]?\d+(?:\.\d+){0,2}[^\+]*)(?:\+.*)?$" DEFAULT_VERSION_SCHEME = "guess-next-dev" DEFAULT_LOCAL_SCHEME = "node-and-date" diff --git a/testing/test_config.py b/testing/test_config.py index b8ea265..49f1d7a 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -11,6 +11,10 @@ import pytest ("apache-arrow-0.9.0", "0.9.0"), ("arrow-0.9.0", "0.9.0"), ("arrow-0.9.0-rc", "0.9.0-rc"), + ("arrow-1", "1"), + ("arrow-1+", "1"), + ("arrow-1+foo", "1"), + ("arrow-1.1+foo", "1.1"), ("v1.1", "v1.1"), ("V1.1", "V1.1"), ], @@ -18,6 +22,7 @@ import pytest def test_tag_regex(tag, expected_version): config = Configuration() match = config.tag_regex.match(tag) + assert match version = match.group("version") assert version == expected_version |