From ad80a3dd2174671d49ef4dd3b431f381d6b0219c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Wed, 25 Mar 2020 14:37:46 +0000 Subject: 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. --- src/setuptools_scm/config.py | 2 +- testing/test_config.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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[vV]?\d+(?:\.\d+){0,2}[^\+]+)(?:\+.*)?$" +DEFAULT_TAG_REGEX = r"^(?:[\w-]+-)?(?P[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 -- cgit v1.2.1