]> snippets.scripts.mit.edu Git - Scripts/git/.git/commitdiff
Display 5 lines instead of 255 chars, and truncate with […].
authorAnders Kaseorg <andersk@mit.edu>
Tue, 30 Jun 2009 21:47:37 +0000 (17:47 -0400)
committerAnders Kaseorg <andersk@mit.edu>
Tue, 30 Jun 2009 21:51:57 +0000 (17:51 -0400)
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
TracZephyrPlugin/ZephyrPlugin.py

index 0f40125be8d2cf7190d6df13cfa346948d547574..88fc2e1aec58031e0f325b7fdb3d5d70f542fc4d 100644 (file)
@@ -21,11 +21,17 @@ class ZephyrPlugin(Component):
         p.stdin.write(message.replace('@', '@@').encode('utf-8', 'replace'))
         p.stdin.close()
         p.wait()
+
+    def format_text(self, text):
+        lines = textwrap.fill(text).split('\n')
+        if len(lines) > 5:
+            lines = lines[:5] + [u'[…]']
+        return '\n'.join(lines)
     
     def ticket_created(self, ticket):
         message = "%s filed a new ticket:\n%s\n\n%s" % (ticket['reporter'],
                                                         ticket['summary'],
-                                                        textwrap.fill(ticket['description'][:255]))
+                                                        self.format_text(ticket['description']))
         self.zwrite(ticket.id, message)
     
     def ticket_changed(self, ticket, comment, author, old_values):