Add signing support for tags in rabbitvcs.

This commit is contained in:
Captain ALM 2024-06-03 14:04:37 +01:00
parent ba37538da5
commit f595f1ad98
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1

View File

@ -765,6 +765,22 @@ class GittyupClient(object):
self._config_set("remote \"origin\"", "url", host)
self.config.write_to_path()
def _get_gpg_sig(self):
try:
config_user_signingkey = S(self._config_get_glb(("user", ), "signingkey"))
if config_user_signingkey == "":
raise KeyError()
except KeyError:
return None
try:
config_commit_gpgsign = S(self._config_get_glb(("commit", ), "gpgsign"))
if config_commit_gpgsign == "" or config_commit_gpgsign.lower() != "true":
raise KeyError()
return config_user_signingkey
except KeyError:
return None
def commit(self, message, parents=None, committer=None, commit_time=None,
commit_timezone=None, author=None, author_time=None,
author_timezone=None, encoding=None, commit_all=False):
@ -817,27 +833,10 @@ class GittyupClient(object):
if commit_timezone is None:
commit_timezone = helper.utc_offset()
try:
config_user_signingkey = S(self._config_get_glb(("user", ), "signingkey"))
if config_user_signingkey == "":
raise KeyError()
except KeyError:
config_user_signingkey = None
config_commit_gpgsign = "false"
if config_user_signingkey is not None:
try:
config_commit_gpgsign = S(self._config_get_glb(("commit", ), "gpgsign"))
if config_commit_gpgsign == "":
raise KeyError()
else:
config_commit_gpgsign = config_commit_gpgsign.lower()
except KeyError:
config_commit_gpgsign = "false"
config_user_signingkey = None
config_user_signingkey = self._get_gpg_sig()
commit_id = None
if config_commit_gpgsign == "true":
if config_user_signingkey is not None:
self.notify("GPG Signing Key: "+S(config_user_signingkey))
commit_id = self.repo.do_commit(**helper.to_bytes({
"message": message,
@ -1362,7 +1361,19 @@ class GittyupClient(object):
@param revision: The revision to tag. Defaults to HEAD
"""
dulwich.porcelain.tag(self.repo, name, objectish=revision, message=message)
config_user_signingkey = self._get_gpg_sig()
if config_user_signingkey is not None:
self.notify("GPG Signing Key: "+S(config_user_signingkey))
if hasattr(dulwich.porcelain,'tag'):
dulwich.porcelain.tag(self.repo, name, objectish=revision, message=message, sign=str(config_user_signingkey))
else:
dulwich.porcelain.tag_create(self.repo, name, objectish=revision, message=message, sign=str(config_user_signingkey))
else:
if hasattr(dulwich.porcelain,'tag'):
dulwich.porcelain.tag(self.repo, name, objectish=revision, message=message)
else:
dulwich.porcelain.tag_create(self.repo, name, objectish=revision, message=message)
def tag_delete(self, name):
"""