summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2018-10-28 19:23:13 +0100
committerGitHub <noreply@github.com>2018-10-28 19:23:13 +0100
commit3ef897a0983dfde7fdfe56a2e9f5f304acdec43e (patch)
tree6221cacbca3b3f6916f314c190000bf1ad15b188
parentb72e86857802b257cc72d420c706624daf5f97ec (diff)
parentf79598b7acc17b8d6c05d7a9fec502f41b7e8be5 (diff)
downloadsetuptools-scm-3ef897a0983dfde7fdfe56a2e9f5f304acdec43e.tar.gz
Merge pull request #316 from 1ucian0/303
adds git describe command option fixes #303 fixes #283
-rw-r--r--CHANGELOG.rst2
-rw-r--r--README.rst7
-rw-r--r--src/setuptools_scm/__init__.py2
-rw-r--r--src/setuptools_scm/config.py1
-rw-r--r--src/setuptools_scm/git.py5
-rw-r--r--testing/test_git.py15
6 files changed, 31 insertions, 1 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 75ba683..daa64e6 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,6 +4,8 @@ v3.1.0
* fix #297 - correct the invocation in version_from_scm and deprecate it as its exposed by accident
* fix #298 - handle git file listing on empty repositories
* fix #268 - deprecate ScmVersion.extra
+* fix #303 and #283 by adding the option `git_describe_command` to allow the user to control the
+way that `git describe` is called.
v3.0.6
======
diff --git a/README.rst b/README.rst
index 4765803..dc7a4d7 100644
--- a/README.rst
+++ b/README.rst
@@ -210,6 +210,13 @@ The currently supported configuration keys are:
defaults to the value of ``setuptools_scm.config.DEFAULT_TAG_REGEX``
(see `config.py <src/setuptools_scm/config.py>`_).
+:git_describe_command:
+ This command will be used instead the default `git describe` command.
+ Use with caution, this is a function for advanced use, and you should be
+ familiar with the setuptools_scm internals to use it.
+
+ The default value is set by ``setuptools_scm.git.DEFAULT_DESCRIBE``
+ (see `git.py <src/setuptools_scm/git.py>`_).
To use setuptools_scm in other Python code you can use the
``get_version`` function:
diff --git a/src/setuptools_scm/__init__.py b/src/setuptools_scm/__init__.py
index 1a39ac0..f49cce4 100644
--- a/src/setuptools_scm/__init__.py
+++ b/src/setuptools_scm/__init__.py
@@ -121,6 +121,7 @@ def get_version(
relative_to=None,
tag_regex=None,
parse=None,
+ git_describe_command=None,
):
"""
If supplied, relative_to should be a file from which root may
@@ -138,6 +139,7 @@ def get_version(
config.relative_to = relative_to
config.tag_regex = tag_regex
config.parse = parse
+ config.git_describe_command = git_describe_command
parsed_version = _do_parse(config)
diff --git a/src/setuptools_scm/config.py b/src/setuptools_scm/config.py
index f62f467..796dd0b 100644
--- a/src/setuptools_scm/config.py
+++ b/src/setuptools_scm/config.py
@@ -61,6 +61,7 @@ class Configuration(object):
self.write_to_template = None
self.parse = None
self.tag_regex = DEFAULT_TAG_REGEX
+ self.git_describe_command = None
@property
def absolute_root(self):
diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py
index 8a91ff3..91644c7 100644
--- a/src/setuptools_scm/git.py
+++ b/src/setuptools_scm/git.py
@@ -101,9 +101,12 @@ def parse(
if pre_parse:
pre_parse(wd)
+ if config.git_describe_command:
+ describe_command = config.git_describe_command
+
out, unused_err, ret = wd.do_ex(describe_command)
if ret:
- # If 'git describe' failed, try to get the information otherwise.
+ # If 'git git_describe_command' failed, try to get the information otherwise.
rev_node = wd.node()
dirty = wd.is_dirty()
diff --git a/testing/test_git.py b/testing/test_git.py
index 11e2d7b..a889293 100644
--- a/testing/test_git.py
+++ b/testing/test_git.py
@@ -191,3 +191,18 @@ def test_git_feature_branch_increments_major(wd):
wd("git checkout -b feature/fun")
wd.commit_testfile()
assert wd.get_version(version_scheme="python-simplified-semver").startswith("1.1.0")
+
+
+@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/303")
+def test_not_matching_tags(wd):
+ wd.commit_testfile()
+ wd("git tag apache-arrow-0.11.1")
+ wd.commit_testfile()
+ wd("git tag apache-arrow-js-0.9.9")
+ wd.commit_testfile()
+ assert wd.get_version(
+ tag_regex=r"^apache-arrow-([\.0-9]+)$",
+ git_describe_command="git describe --dirty --tags --long --exclude *js* ",
+ ).startswith(
+ "0.11.2"
+ )