Commits

Thejesh GN committed a3314b7

Shows keyid and name for GPG sigs

  • Participants
  • Parent commits 390db25

Comments (0)

Files changed (1)

File commitsigs.py

 """
 
 import os, tempfile, subprocess, binascii, shlex
-
+import re
 from mercurial import (util, cmdutil, extensions, revlog, error,
                        encoding, changelog)
 from mercurial.node import short, hex, nullid
         p = subprocess.Popen(cmd, stdin=subprocess.PIPE,
                              stdout=subprocess.PIPE, stderr=stderr)
         out, err = p.communicate(msg)
-        return 'GOODSIG' in out
+        if 'GOODSIG' in out:
+            m = re.search('GOODSIG.*\n', out)            
+            return (True, m.group(0).replace('GOODSIG',''))
+        else:
+            return (False, "No Match")
     finally:
         try:
             os.unlink(filename)
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
         out, err = p.communicate(sig)
-        return err.strip() == "Verification successful"
+        if err.strip() == "Verification successful":
+            return (True, "Verification successful")
+        else:
+            return (False, "Verification NOT successful")
     finally:
         try:
             os.unlink(filename)
             try:
                 scheme, sig = sig.split(":", 1)
                 verifyfunc = sigschemes[scheme][1]
-                if verifyfunc(hex(h), sig, quiet=True):
-                    msg = _("good %s signature") % scheme
+                verifyfunc_results = verifyfunc(hex(h), sig, quiet=True)
+                if verifyfunc_results[0]:
+                    msg = _("Good %s signature by %s") % (scheme, verifyfunc_results[1])
                 else:
                     msg = _("** bad %s signature on %s") % (scheme, short(h))
                     retcode = max(retcode, 3)