summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.rst5
-rw-r--r--src/setuptools_scm/git.py3
-rw-r--r--testing/test_git.py11
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