]> snippets.scripts.mit.edu Git - Scripts/git/.git/blobdiff - TracZephyrPlugin/ZephyrPlugin.py
TracZephyrPlugin: Smarter quoted text regex.
[Scripts/git/.git] / TracZephyrPlugin / ZephyrPlugin.py
index 87c8762d7756c48a1a41ca637aab29bb6279b266..679d019f962274877cc4bfb63e32cd3a905b6be8 100644 (file)
@@ -1,9 +1,14 @@
+# -*- coding: utf-8 -*-
+
 from trac.core import *
 from trac.ticket import ITicketChangeListener
 import subprocess
+import re
 import textwrap
 import shlex
 
+quoted_re = re.compile('^(?:> ?\n)*> .+\n(?:>(?: .*)?\n)*', re.MULTILINE)
+
 class ZephyrPlugin(Component):
     implements(ITicketChangeListener)
     
@@ -23,6 +28,7 @@ class ZephyrPlugin(Component):
         p.wait()
 
     def format_text(self, text):
+        text = re.sub(quoted_re, u'> […]\n', text)
         lines = textwrap.fill(text).split('\n')
         if len(lines) > 5:
             lines = lines[:5] + [u'[…]']
@@ -35,7 +41,7 @@ class ZephyrPlugin(Component):
         self.zwrite(ticket.id, message)
     
     def ticket_changed(self, ticket, comment, author, old_values):
-        message = ''
+        message = "(%s)\n" % ticket['summary']
         for field in ticket.fields:
             name = field['name']
             if name not in old_values: