]> snippets.scripts.mit.edu Git - Scripts/git/.git/commitdiff
TracZephyrPlugin: Smarter quoted text regex.
authorAnders Kaseorg <andersk@mit.edu>
Fri, 18 Dec 2009 00:52:01 +0000 (19:52 -0500)
committerAnders Kaseorg <andersk@mit.edu>
Sun, 27 Dec 2009 10:26:15 +0000 (05:26 -0500)
Some mail clients quote an empty line as ‘>’ instead of ‘> ’.  Also
check that at least one of the quoted lines is nonempty.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
TracZephyrPlugin/ZephyrPlugin.py

index 45584ae80bda02ead02c4e558a8a877b46eb34c2..679d019f962274877cc4bfb63e32cd3a905b6be8 100644 (file)
@@ -7,6 +7,8 @@ import re
 import textwrap
 import shlex
 
+quoted_re = re.compile('^(?:> ?\n)*> .+\n(?:>(?: .*)?\n)*', re.MULTILINE)
+
 class ZephyrPlugin(Component):
     implements(ITicketChangeListener)
     
@@ -26,7 +28,7 @@ class ZephyrPlugin(Component):
         p.wait()
 
     def format_text(self, text):
-        text = re.sub(re.compile('^(?:> .*\n)+', re.MULTILINE), u'> […]\n', text)
+        text = re.sub(quoted_re, u'> […]\n', text)
         lines = textwrap.fill(text).split('\n')
         if len(lines) > 5:
             lines = lines[:5] + [u'[…]']