summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorXiao Di Guan <xdg@puxlit.net>2022-02-08 00:14:55 +1100
committerXiao Di Guan <xdg@puxlit.net>2022-02-08 01:31:21 +1100
commite23cbb6f37d24f33e705dc343a4e7cd080d8cf1d (patch)
tree84ac7211c501e407adf6f621b8f1e4fb4c90a70c /testing
parent38d79e03f64b25d6b26623b8e0c26fe6cb9067d5 (diff)
downloadsetuptools-scm-e23cbb6f37d24f33e705dc343a4e7cd080d8cf1d.tar.gz
Add test case for #548
Diffstat (limited to 'testing')
-rw-r--r--testing/test_git.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/testing/test_git.py b/testing/test_git.py
index b1b42ac..0e42905 100644
--- a/testing/test_git.py
+++ b/testing/test_git.py
@@ -402,3 +402,35 @@ def test_git_getdate_badgit(
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
+
+
+@pytest.fixture
+def signed_commit_wd(tmp_path, monkeypatch, wd):
+ if not has_command("gpg", warn=False):
+ pytest.skip("gpg executable not found")
+
+ gpg_batch_params = tmp_path / "gpg_batch_params"
+ gpg_batch_params.write_text(
+ """\
+%no-protection
+%transient-key
+Key-Type: default
+Name-Real: a test
+Name-Email: test@example.com
+Expire-Date: 0
+"""
+ )
+ monkeypatch.setenv("GNUPGHOME", str(tmp_path))
+ wd(f"gpg --batch --generate-key {gpg_batch_params}")
+
+ wd("git config log.showSignature true")
+ wd.signed_commit_command = "git commit -S -m test-{reason}"
+ return wd
+
+
+@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/548")
+def test_git_getdate_signed_commit(signed_commit_wd):
+ today = date.today()
+ signed_commit_wd.commit_testfile(signed=True)
+ git_wd = git.GitWorkdir(os.fspath(signed_commit_wd.cwd))
+ assert git_wd.get_head_date() == today