[Patchew-devel] [PATCH 2/3] patchew-cli: process headers for project update in Python

Paolo Bonzini posted 3 patches 4 years, 6 months ago
[Patchew-devel] [PATCH 2/3] patchew-cli: process headers for project update in Python
Posted by Paolo Bonzini 4 years, 6 months ago
This will make it easier to match more cases.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 patchew-cli | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/patchew-cli b/patchew-cli
index b8ac054..d29b539 100755
--- a/patchew-cli
+++ b/patchew-cli
@@ -491,14 +491,16 @@ class ProjectCommand(SubCommand):
         logging.debug("old head: %s", old_head)
         logging.debug("new commits: \n%s" % "\n".join(["  " + x for x in new_commits]))
         output = subprocess.check_output(
-            """git show --format=%%b %s |
-                awk 'BEGIN{IGNORECASE=1} /^message-id:/{print}'
-                """
-            % " ".join(new_commits),
-            shell=True,
+            ["git", "show", "--format=%b"] + new_commits,
             cwd=clone,
         ).decode()
-        msgids = [x[len("message-id:") :].strip() for x in output.splitlines()]
+        msgid_trailer = 'Message-Id:'.casefold()
+        msgids = []
+        for x in output.splitlines():
+            words = x.split()
+            header = x.casefold()
+            if header.startswith(msgid_trailer):
+                msgids.append(x[11:].strip())
         logging.debug("message ids: \n%s" % "\n".join(["  " + x for x in msgids]))
         push_to = project["mirror"].get("pushurl")
         if push_to:
-- 
2.34.1


_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/patchew-devel