Skip to contentSkip to conversation

Parsemail: Improve references/pull-request search

PATCH New Jose Lamego 1 participant 3 messages Nov 24, 2016

lore
Share & tools
lore
#0 lore raw

cover Parsemail: Improve references/pull-request search

These changes are to improve the way email-chain references are created and pull-request information to be included even with small formatting variations.

Jose Lamego (2):
patchwork.bin.parsemail: Use oldest header references patchwork.bin.parsemail: Improve pull-request regex

 patchwork/bin/parsemail.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

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

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]

---
 patchwork/bin/parsemail.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
patchwork/bin/parsemail.py +12 -3
index 47b535f..c10bed5 100755
@@ -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"""
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/2 patchwork.bin.parsemail: Improve pull-request regex

In reply to Jose Lamego

Some patch messages containinig pull-request information are being skipped due to formatting variations.

This change improves the pull-request search to include those small variants.

---
 patchwork/bin/parsemail.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
patchwork/bin/parsemail.py +2 -2
index c10bed5..476118d 100755
@@ -195,8 +195,8 @@ def mail_headers(mail):
 
 def find_pull_request(content):
     git_re = re.compile(r'^The following changes since commit.*' +
-                        r'^are available in the git repository at:\n'
-                        r'^\s*([\S]+://[^\n]+)$',
+                        r'^are available in the git repository at:.*'+
+                        r'^\s*([\S]+://[^\n]+)[$]*',
                         re.DOTALL | re.MULTILINE)
     match = git_re.search(content)
     if match:
Signature · 1 line
1.9.1