signatures.lore.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] Fix lookups for uncommitted keys
@ 2021-06-03 17:18 Konstantin Ryabitsev
  2021-06-03 17:18 ` [PATCH 2/5] Add "frequently seen commentary" Konstantin Ryabitsev
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Konstantin Ryabitsev @ 2021-06-03 17:18 UTC (permalink / raw)
  To: signatures

Fix for the case when a key is added the repository but hasn't been
committed yet -- we were looking for it in the wrong subpath.

Signed-off-by: Konstantin Ryabitsev <konstantin.ryabitsev@linux.dev>
---
 patatt/__init__.py | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/patatt/__init__.py b/patatt/__init__.py
index 9602392..460d282 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.3'
+__VERSION__ = '0.4.4'
 MAX_SUPPORTED_FORMAT_VERSION = 1
 
 
@@ -723,19 +723,21 @@ def get_public_key(source: str, keytype: str, identity: str, selector: str) -> T
         parts = source.split(':', 4)
         if len(parts) < 4:
             raise ConfigurationError('Invalid ref, must have at least 3 colons: %s' % source)
-        gittop = parts[1]
+        gitrepo = parts[1]
         gitref = parts[2]
         gitsub = parts[3]
-        if not gittop:
-            gittop = get_git_toplevel()
-        if not gittop:
-            raise KeyError('Not in a git tree, so cannot use a ref: source')
-
-        gittop = os.path.expanduser(gittop)
-        if gittop.find('$') >= 0:
-            gittop = os.path.expandvars(gittop)
-        if os.path.isdir(os.path.join(gittop, '.git')):
-            gittop = os.path.join(gittop, '.git')
+        if not gitrepo:
+            gitrepo = get_git_toplevel()
+        if not gitrepo:
+            raise KeyError('Not in a git tree, so cannot use a ref:: source')
+
+        gitrepo = os.path.expanduser(gitrepo)
+        if gitrepo.find('$') >= 0:
+            gitrepo = os.path.expandvars(gitrepo)
+        if os.path.isdir(os.path.join(gitrepo, '.git')):
+            gittop = os.path.join(gitrepo, '.git')
+        else:
+            gittop = gitrepo
 
         # it could omit the refspec, meaning "whatever the current ref"
         # grab the key from a fully ref'ed path
@@ -767,8 +769,8 @@ def get_public_key(source: str, keytype: str, identity: str, selector: str) -> T
             logger.debug('KEYSRC  : %s', keysrc)
             return out, 'ref:%s:%s' % (gittop, keysrc)
 
-        # Does it exist on disk in gittop?
-        fullpath = os.path.join(gittop, subpath)
+        # Does it exist on disk but hasn't been committed yet?
+        fullpath = os.path.join(gitrepo, subpath)
         if os.path.exists(fullpath):
             with open(fullpath, 'rb') as fh:
                 logger.debug('KEYSRC  : %s', fullpath)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-03 17:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 17:18 [PATCH 1/5] Fix lookups for uncommitted keys Konstantin Ryabitsev
2021-06-03 17:18 ` [PATCH 2/5] Add "frequently seen commentary" Konstantin Ryabitsev
2021-06-03 17:18 ` [PATCH 3/5] Handle MIME encoded-word & other header manglings Konstantin Ryabitsev
2021-06-03 17:18 ` [PATCH 4/5] Make instructions for automatic signing more reliable Konstantin Ryabitsev
2021-06-03 17:18 ` [PATCH 5/5] Throw a NoKeyError when no matching PGP key Konstantin Ryabitsev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).