diff mbox

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

Message ID 1441986924-26689-8-git-send-email-damien.lespiau@intel.com
State Superseded
Headers show

Commit Message

Damien Lespiau Sept. 11, 2015, 3:54 p.m. UTC
Those signature don't really add value to the comment.

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

Patch

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: