diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-09-13 17:05:27 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-09-13 17:05:27 -0400 |
commit | a7653256be70d99c9f6749bf5872d2fb984ddc22 (patch) | |
tree | 1b126a3c465d80edb3c74f05cf07be11d47dff0d | |
parent | 2613bae14352346cabcd66688366ebfaff959aa5 (diff) | |
download | patatt-a7653256be70d99c9f6749bf5872d2fb984ddc22.tar.gz |
Use a symlink to make the new key defaultv0.4.8
When we're creating our very first ed25519 key, use the selector name
and symlink it to be the default key for that identity instead of just
writing it out into "default". This allows us to do the following with
the default configuration:
git format-patch -1 --stdout | patatt sign | patatt validate
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | patatt/__init__.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/patatt/__init__.py b/patatt/__init__.py index 4262a4a..41b7dfd 100644 --- a/patatt/__init__.py +++ b/patatt/__init__.py @@ -47,7 +47,7 @@ OPT_HDRS = [b'message-id'] KEYCACHE = dict() # My version -__VERSION__ = '0.4.7' +__VERSION__ = '0.4.8' MAX_SUPPORTED_FORMAT_VERSION = 1 @@ -1089,17 +1089,15 @@ def cmd_genkey(cmdargs, config: dict) -> None: logger.critical('Wrote: %s', pkey) # Also copy it into our local keyring + spkey = os.path.join(pdir, make_pkey_path('ed25519', config.get('identity'), identifier)) + Path(os.path.dirname(spkey)).mkdir(parents=True, exist_ok=True) + with open(spkey, 'wb') as fh: + fh.write(base64.b64encode(newkey.verify_key.encode())) + logger.critical('Wrote: %s', spkey) dpkey = os.path.join(pdir, make_pkey_path('ed25519', config.get('identity'), 'default')) - Path(os.path.dirname(dpkey)).mkdir(parents=True, exist_ok=True) if not os.path.exists(dpkey): - with open(dpkey, 'wb') as fh: - fh.write(base64.b64encode(newkey.verify_key.encode())) - logger.critical('Wrote: %s', dpkey) - else: - spkey = os.path.join(pdir, make_pkey_path('ed25519', config.get('identity'), identifier)) - with open(spkey, 'wb') as fh: - fh.write(base64.b64encode(newkey.verify_key.encode())) - logger.critical('Wrote: %s', spkey) + # symlink our new key to be the default + os.symlink(identifier, dpkey) logger.critical('Add the following to your .git/config (or global ~/.gitconfig):') logger.critical('---') |