diff --git a/Add-option-git_describe_command.patch b/Add-option-git_describe_command.patch new file mode 100644 index 0000000000000000000000000000000000000000..66d64b0dd31ef961cea7963369e94571daa688cb --- /dev/null +++ b/Add-option-git_describe_command.patch @@ -0,0 +1,122 @@ +From f79598b7acc17b8d6c05d7a9fec502f41b7e8be5 Mon Sep 17 00:00:00 2001 +From: Luciano Bello +Date: Sat, 27 Oct 2018 16:11:55 -0400 +Subject: [PATCH] Add option git_describe_command + +The option git_describe_command is added to allow the user to manipulate how `git describe` is called. + +Fixes #303 +Fixes #283 +--- + CHANGELOG.rst | 2 ++ + README.rst | 7 +++++++ + src/setuptools_scm/__init__.py | 2 ++ + src/setuptools_scm/config.py | 1 + + src/setuptools_scm/git.py | 5 ++++- + testing/test_git.py | 15 +++++++++++++++ + 6 files changed, 31 insertions(+), 1 deletion(-) + +diff --git a/CHANGELOG.rst b/CHANGELOG.rst +index 75ba683f..daa64e6e 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 4765803b..dc7a4d7d 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 `_). + ++: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 `_). + + 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 1a39ac0b..f49cce40 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 f62f467d..796dd0ba 100644 +--- a/src/setuptools_scm/config.py ++++ b/src/setuptools_scm/config.py +@@ -61,6 +61,7 @@ def __init__(self, relative_to=None, root="."): + 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 8a91ff3c..91644c7f 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 11e2d7b5..a889293b 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" ++ ) diff --git a/python-setuptools_scm.spec b/python-setuptools_scm.spec index 6592068e5313a39de36a9ec3708eefb3ed4a4d40..b95c923e44f4aeaf8a8e9a97fda37a6bcdf7be37 100644 --- a/python-setuptools_scm.spec +++ b/python-setuptools_scm.spec @@ -1,11 +1,11 @@ Name: python-setuptools_scm Version: 3.1.0 -Release: 2 +Release: 3 Summary: Manage your Python package versions in SCM metadata License: MIT URL: https://pypi.python.org/pypi/setuptools_scm Source0: https://files.pythonhosted.org/packages/source/%(n=setuptools_scm; echo ${n:0:1})/setuptools_scm/setuptools_scm-%{version}.tar.gz - +Patch0: Add-option-git_describe_command.patch BuildArch: noarch BuildRequires: git-core mercurial @@ -41,7 +41,7 @@ instead of declaring them as the version argument or in a SCM managed file. It also handles file finders for the supported SCMs. %prep -%autosetup -n setuptools_scm-%{version} +%autosetup -n setuptools_scm-%{version} -p1 %build %py2_build @@ -71,6 +71,9 @@ PYTHONPATH=%{buildroot}%{python2_sitelib} py.test-%{python3_version} -v -k 'not %{python3_sitelib}/setuptools_scm-*.egg-info %changelog +* Thu Sep 09 2021 huanghaitao - 3.1.0-3 +- Add option git_describe_command to fix python-cmd2 build error + * Tue Dec 10 2019 openEuler Buildteam - 3.1.0-2 - Modify spec format.