[PATCH] Support SSH user.signingkey

Bingwu Zhang <[email protected]>
Newsgroups org.kernel.linux.tools
Message-ID <[email protected]>
From: Bingwu Zhang <[email protected]>

Check gpg.format to see if user.signingkey is a SSH
key.

Signed-off-by: Bingwu Zhang <[email protected]>
---
 src/patatt/__init__.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/patatt/__init__.py b/src/patatt/__init__.py
index ae8f21ea104f..ac610b87bc6d 100644
--- a/src/patatt/__init__.py
+++ b/src/patatt/__init__.py
@@ -1312,10 +1312,13 @@ def get_algo_keydata(config: GitConfigType) -> Tuple[str, str]:
         return algo, keydata
 
     if not config.get('signingkey'):
-        if usercfg.get('signingkey'):
-            logger.info('N: Using pgp key %s defined by user.signingkey', usercfg.get('signingkey'))
+        user_signingkey = usercfg.get('signingkey')
+        if user_signingkey:
+            gpg_format = get_config_from_git(r'gpg\..*').get('format', 'gpg')
+            key_algo = 'openssh' if gpg_format == 'ssh' else 'openpgp'
+            logger.info('N: Using %s key %s defined by user.signingkey', key_algo, user_signingkey)
             logger.info('N: Override by setting patatt.signingkey')
-            config['signingkey'] = 'openpgp:%s' % usercfg.get('signingkey')
+            config['signingkey'] = '%s:%s' % (key_algo, user_signingkey)
         else:
             logger.critical('E: patatt.signingkey is not set')
             logger.critical('E: Perhaps you need to run genkey first?')

base-commit: d8ea60b65cad9b92003eef92153457736652e2bd
-- 
2.52.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.