[PATCH 07/51] parsemail: Strip mail signatures from comments

Damien Lespiau damien.lespiau at intel.com
Sat Sep 12 01:54:40 AEST 2015


Those signature don't really add value to the comment.

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 patchwork/bin/parsemail.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py
index a622187..873415d 100755
--- a/patchwork/bin/parsemail.py
+++ b/patchwork/bin/parsemail.py
@@ -149,7 +149,6 @@ def find_pull_request(content):
         return match.group(1)
     return None
 
-
 def try_decode(payload, charset):
     try:
         payload = unicode(payload, charset)
@@ -157,6 +156,20 @@ def try_decode(payload, charset):
         return None
     return payload
 
+def strip_signature(text):
+    if not text:
+        return
+
+    buf = ''
+    for line in text.splitlines(True):
+        if line == '-- \n':
+            break
+        buf += line
+
+    if buf == '':
+        return None
+    return buf.strip()
+
 class MailContent:
     def __init__(self):
         self.patch = None
@@ -245,6 +258,8 @@ def find_content(project, mail):
             if c is not None:
                 commentbuf += c.strip() + '\n'
 
+    commentbuf = strip_signature(commentbuf)
+
     ret = MailContent()
 
     if pullurl or patchbuf:
-- 
2.1.0



More information about the Patchwork mailing list