summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2018-07-23 20:10:26 +0200
committerGitHub <noreply@github.com>2018-07-23 20:10:26 +0200
commit6f2703342a7060c4673117e54d9a0c133a07211e (patch)
tree4b0d74a4e6d96cb6b14a09ca73c9e513bc1ba80e
parent3214d3e665b296a85f12fc1c20430b311d7f2975 (diff)
parented9b1123b1e9c7c3a62c3ab12ea8ac30231a1327 (diff)
downloadsetuptools-scm-6f2703342a7060c4673117e54d9a0c133a07211e.tar.gz
Merge pull request #285 from RonnyPfannschmidt/fix-284v3.0.2
fix #284 - allow dashes in default tag prefixes again
-rw-r--r--CHANGELOG.rst8
-rw-r--r--src/setuptools_scm/__init__.py23
-rw-r--r--src/setuptools_scm/config.py25
-rw-r--r--testing/test_config.py18
4 files changed, 54 insertions, 20 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index bd68fab..ea83b4e 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,7 +1,13 @@
+v3.0.2
+======
+
+* fix a regression from tag parsing - support for multi-dashed prefixes - #284
+
+
v3.0.1
=======
-* fix a regression in setuptools_scm.git.parse - reorder arguments so the positional invocation from before works as expected
+* fix a regression in setuptools_scm.git.parse - reorder arguments so the positional invocation from before works as expected #281
v3.0.0
=======
diff --git a/src/setuptools_scm/__init__.py b/src/setuptools_scm/__init__.py
index 58be234..49c0c4b 100644
--- a/src/setuptools_scm/__init__.py
+++ b/src/setuptools_scm/__init__.py
@@ -29,10 +29,14 @@ def version_from_scm(root):
def _call_entrypoint_fn(config, fn):
- if function_has_arg(fn, 'config'):
+ if function_has_arg(fn, "config"):
return fn(config.absolute_root, config=config)
else:
- warnings.warn("parse functions are required to provide a named argument 'config' in the future.", PendingDeprecationWarning)
+ warnings.warn(
+ "parse functions are required to provide a named argument"
+ " 'config' in the future.",
+ PendingDeprecationWarning,
+ )
return fn(config.absolute_root)
@@ -75,13 +79,16 @@ def _do_parse(config):
raise TypeError(
"version parse result was a string\nplease return a parsed version"
)
- version = parse_result or \
- _version_from_entrypoint(config, "setuptools_scm.parse_scm_fallback")
-
+ version = parse_result or _version_from_entrypoint(
+ config, "setuptools_scm.parse_scm_fallback"
+ )
else:
# include fallbacks after dropping them from the main entrypoint
- version = _version_from_entrypoint(config, "setuptools_scm.parse_scm") or \
- _version_from_entrypoint(config, "setuptools_scm.parse_scm_fallback")
+ version = _version_from_entrypoint(
+ config, "setuptools_scm.parse_scm"
+ ) or _version_from_entrypoint(
+ config, "setuptools_scm.parse_scm_fallback"
+ )
if version:
return version
@@ -114,7 +121,7 @@ def get_version(
in the root of the repository to direct setuptools_scm to the
root of the repository by supplying ``__file__``.
"""
-
+
config = Configuration()
config.root = root
config.version_scheme = version_scheme
diff --git a/src/setuptools_scm/config.py b/src/setuptools_scm/config.py
index dbd3768..b1c07f8 100644
--- a/src/setuptools_scm/config.py
+++ b/src/setuptools_scm/config.py
@@ -6,8 +6,8 @@ import warnings
from .utils import trace
-DEFAULT_TAG_REGEX = r'^(?:\w+-)?(?P<version>v?\d+(?:\.\d+){0,2}[^\+]+)(?:\+.*)?$'
-DEFAULT_VERSION_SCHEME = 'version_scheme'
+DEFAULT_TAG_REGEX = r"^(?:[\w-]+-)?(?P<version>v?\d+(?:\.\d+){0,2}[^\+]+)(?:\+.*)?$"
+DEFAULT_VERSION_SCHEME = "version_scheme"
def _check_tag_regex(value):
@@ -16,9 +16,11 @@ def _check_tag_regex(value):
regex = re.compile(value)
group_names = regex.groupindex.keys()
- if regex.groups == 0 or (regex.groups > 1 and 'version' not in group_names):
- warnings.warn("Expected tag_regex to contain a single match group or a group named 'version' " +
- "to identify the version part of any tag.")
+ if regex.groups == 0 or (regex.groups > 1 and "version" not in group_names):
+ warnings.warn(
+ "Expected tag_regex to contain a single match group or a group named"
+ " 'version' to identify the version part of any tag."
+ )
return regex
@@ -26,7 +28,10 @@ def _check_tag_regex(value):
def _check_absolute_root(root, relative_to):
if relative_to:
if os.path.isabs(root) and not root.startswith(relative_to):
- warnings.warn("absolute root path '%s' overrides relative_to '%s'" % (root, relative_to))
+ warnings.warn(
+ "absolute root path '%s' overrides relative_to '%s'"
+ % (root, relative_to)
+ )
root = os.path.join(os.path.dirname(relative_to), root)
return os.path.abspath(root)
@@ -44,17 +49,15 @@ class Configuration(object):
_tag_regex = None
_absolute_root = None
- def __init__(self,
- relative_to=None,
- root='.'):
+ def __init__(self, relative_to=None, root="."):
# TODO:
self._relative_to = relative_to
- self._root = '.'
+ self._root = "."
self.root = root
self.version_scheme = DEFAULT_VERSION_SCHEME
self.local_scheme = "node-and-date"
- self.write_to = ''
+ self.write_to = ""
self.write_to_template = None
self.parse = None
self.tag_regex = DEFAULT_TAG_REGEX
diff --git a/testing/test_config.py b/testing/test_config.py
new file mode 100644
index 0000000..89181b8
--- /dev/null
+++ b/testing/test_config.py
@@ -0,0 +1,18 @@
+from setuptools_scm.config import Configuration
+
+import pytest
+
+
+@pytest.mark.parametrize(
+ "tag, expected_version",
+ [
+ ("apache-arrow-0.9.0", "0.9.0"),
+ ("arrow-0.9.0", "0.9.0"),
+ ("arrow-0.9.0-rc", "0.9.0-rc"),
+ ],
+)
+def test_tag_regex(tag, expected_version):
+ config = Configuration()
+ match = config.tag_regex.match(tag)
+ version = match.group("version")
+ assert version == expected_version