[yocto] [patchwork][PATCH 1/2] patchwork.bin.parsemail: Use oldest header references

Jose Lamego jose.a.lamego at linux.intel.com
Thu Nov 24 07:27:38 PST 2016


References list for previous emails only include first found
header, causing that some root messages for series are skipped
and corresponding series revision numbering gets corrupted.

This change forces references list to use last header found,
allowing for Patch emails created with send-pull-request script
to be appropriately appended to last revision.

[Yocto #9941]

Signed-off-by: Jose Lamego <jose.a.lamego at linux.intel.com>
---
 patchwork/bin/parsemail.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py
index 47b535f..c10bed5 100755
--- a/patchwork/bin/parsemail.py
+++ b/patchwork/bin/parsemail.py
@@ -284,9 +284,18 @@ def build_references_from_db(msgid):
 
 
 def build_references_from_mail(mail):
-    return build_references_from_headers(mail.get('In-Reply-To', None),
-                                         mail.get('References', None))
-
+    replies = ""
+    references = ""
+    parser = HeaderParser()
+    headers = parser.parsestr(mail.as_string())
+    for h in headers.items():
+        # Patch emails created with send-pull-Request script
+        # may contain two set of references, so use only the last found
+        if h[0] == 'In-Reply-To':
+            replies = "%s" % h[1]
+        if h[0] == 'References':
+            references = "%s" % h[1]
+    return build_references_from_headers(replies, references)
 
 def build_references_list(mail):
     """Construct the list of msgids from 'mail' to the root of the thread"""
-- 
1.9.1




More information about the yocto mailing list