diff options
| author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2021-03-17 15:11:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-17 15:11:55 +0100 |
| commit | abb67b15985f380d8cf4451b9f2ef3dd11cb8a91 (patch) | |
| tree | c5736d699b740b8cc6820bbbf39f3aca8f6dcd2e | |
| parent | 53c16ce378cae61adb970c731f95fcdcd5fdf12b (diff) | |
| parent | 32ab7e6d45fbbc221fb98b3783fb34933fc9b1dc (diff) | |
| download | setuptools-scm-6.0.1.tar.gz | |
Merge pull request #538 from RonnyPfannschmidt/fix-537-drop-node-date-on-old-gitv6.0.1
drop node_date on old git
| -rw-r--r-- | CHANGELOG.rst | 5 | ||||
| -rw-r--r-- | src/setuptools_scm/git.py | 3 | ||||
| -rw-r--r-- | testing/test_git.py | 11 |
3 files changed, 18 insertions, 1 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2bfe2d9..ecbcf81 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +v6.0.1 +======= + +* fix #537: drop node_date on old git to avoid errors on missing %cI + v6.0.0 ====== diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py index b1a85ab..c7f301b 100644 --- a/src/setuptools_scm/git.py +++ b/src/setuptools_scm/git.py @@ -61,6 +61,9 @@ class GitWorkdir: return # TODO, when dropping python3.6 use fromiso date_part = timestamp.split("T")[0] + if "%c" in date_part: + trace("git too old -> timestamp is ", timestamp) + return None return datetime.strptime(date_part, r"%Y-%m-%d").date() def is_shallow(self): diff --git a/testing/test_git.py b/testing/test_git.py index d934c02..8080574 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -8,7 +8,7 @@ from datetime import datetime from os.path import join as opj from setuptools_scm.file_finder_git import git_find_files from datetime import date - +from unittest.mock import patch, Mock pytestmark = pytest.mark.skipif( not has_command("git", warn=False), reason="git executable not found" @@ -307,3 +307,12 @@ def test_git_getdate(wd): assert git_wd.get_head_date() == today meta = git.parse(os.fspath(wd.cwd)) assert meta.node_date == today + + +def test_git_getdate_badgit( + wd, +): + wd.commit_testfile() + git_wd = git.GitWorkdir(os.fspath(wd.cwd)) + with patch.object(git_wd, "do_ex", Mock(return_value=("%cI", "", 0))): + assert git_wd.get_head_date() is None |
