|
@@ -0,0 +1,97 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+"""Compatibility tests for dulwich.porcelain."""
|
|
|
+
|
|
|
+import os
|
|
|
+import platform
|
|
|
+import sys
|
|
|
+from unittest import skipIf
|
|
|
+
|
|
|
+from dulwich import porcelain
|
|
|
+from dulwich.tests.utils import (
|
|
|
+ build_commit_graph,
|
|
|
+)
|
|
|
+from dulwich.tests.compat.utils import (
|
|
|
+ run_git_or_fail,
|
|
|
+ CompatTestCase,
|
|
|
+)
|
|
|
+from dulwich.tests.test_porcelain import (
|
|
|
+ PorcelainGpgTestCase,
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
+@skipIf(platform.python_implementation() == "PyPy" or sys.platform == "win32", "gpgme not easily available or supported on Windows and PyPy")
|
|
|
+class TagCreateSignTestCase(PorcelainGpgTestCase, CompatTestCase):
|
|
|
+ def setUp(self):
|
|
|
+ super(TagCreateSignTestCase, self).setUp()
|
|
|
+
|
|
|
+ def test_sign(self):
|
|
|
+
|
|
|
+ c1, c2, c3 = build_commit_graph(
|
|
|
+ self.repo.object_store, [[1], [2, 1], [3, 1, 2]]
|
|
|
+ )
|
|
|
+ self.repo.refs[b"HEAD"] = c3.id
|
|
|
+ cfg = self.repo.get_config()
|
|
|
+ cfg.set(("user",), "signingKey", PorcelainGpgTestCase.DEFAULT_KEY_ID)
|
|
|
+ self.import_default_key()
|
|
|
+
|
|
|
+ porcelain.tag_create(
|
|
|
+ self.repo.path,
|
|
|
+ b"tryme",
|
|
|
+ b"foo <foo@bar.com>",
|
|
|
+ b"bar",
|
|
|
+ annotated=True,
|
|
|
+ sign=True,
|
|
|
+ )
|
|
|
+
|
|
|
+ run_git_or_fail(
|
|
|
+ [
|
|
|
+ "--git-dir={}".format(self.repo.controldir()),
|
|
|
+ "tag",
|
|
|
+ "-v",
|
|
|
+ "tryme"
|
|
|
+ ],
|
|
|
+ env=os.environ.copy(),
|
|
|
+ )
|
|
|
+
|
|
|
+ def test_verify(self):
|
|
|
+
|
|
|
+ c1, c2, c3 = build_commit_graph(
|
|
|
+ self.repo.object_store, [[1], [2, 1], [3, 1, 2]]
|
|
|
+ )
|
|
|
+ self.repo.refs[b"HEAD"] = c3.id
|
|
|
+ self.import_default_key()
|
|
|
+
|
|
|
+ run_git_or_fail(
|
|
|
+ [
|
|
|
+ "--git-dir={}".format(self.repo.controldir()),
|
|
|
+ "tag",
|
|
|
+ "-u",
|
|
|
+ PorcelainGpgTestCase.DEFAULT_KEY_ID,
|
|
|
+ "-m",
|
|
|
+ "foo",
|
|
|
+ "verifyme",
|
|
|
+ ],
|
|
|
+ env=os.environ.copy(),
|
|
|
+ )
|
|
|
+ tag = self.repo[b"refs/tags/verifyme"]
|
|
|
+ self.assertNotEqual(tag.signature, None)
|
|
|
+ tag.verify()
|