Put the ticket URL in the zsig
authorAlex Dehnert <adehnert@mit.edu>
Mon, 20 May 2013 08:33:34 +0000 (04:33 -0400)
committerAlex Dehnert <adehnert@mit.edu>
Mon, 20 May 2013 08:33:34 +0000 (04:33 -0400)
TracZephyrPlugin/ZephyrPlugin.py
TracZephyrPlugin/setup.py

index 673c339b99dfd5eff8b2b571dfa855a5e6f83315..a1978b611098f892c60599e1de45fb07d42a15f6 100644 (file)
@@ -12,7 +12,7 @@ quoted_re = re.compile('^(?:> ?\n)*> .+\n(?:>(?: .*)?\n)*', re.MULTILINE)
 class ZephyrPlugin(Component):
     implements(ITicketChangeListener)
     
-    def zwrite(self, id, message):
+    def zwrite(self, id, message, extra_sig=None):
         zclass = self.config.get('ZephyrPlugin', 'class')
         if zclass == '':
             return
@@ -23,6 +23,11 @@ class ZephyrPlugin(Component):
         if opcode:
             command += ['-O', opcode]
         signature = self.config.get('ZephyrPlugin', 'signature')
+        if extra_sig:
+            if signature:
+                signature = "%s: %s" % (signature, extra_sig, )
+            else:
+                signature = extra_sig
         if signature:
             command += ['-s', signature]
         p = subprocess.Popen(command +
@@ -40,6 +45,9 @@ class ZephyrPlugin(Component):
             lines = lines[:5] + [u'[…]']
         return '\n'.join(lines)
     
+    def get_url(self, ticket):
+        return ticket.env.abs_href.ticket(ticket.id)
+
     def ticket_created(self, ticket):
         ttype='ticket'
         if ticket['type'] != 'defect':
@@ -49,7 +57,7 @@ class ZephyrPlugin(Component):
                                                            ttype,
                                                            ticket['summary'],
                                                            self.format_text(ticket['description']))
-        self.zwrite(ticket.id, message)
+        self.zwrite(ticket.id, message, extra_sig=self.get_url(ticket))
     
     def ticket_changed(self, ticket, comment, author, old_values):
         message = "(%s)\n" % ticket['summary']
@@ -69,8 +77,8 @@ class ZephyrPlugin(Component):
                 message += "%s changed %s.\n" % (author, name)
         if comment:
             message += "%s commented:\n%s\n" % (author, self.format_text(comment))
-        self.zwrite(ticket.id, message)
+        self.zwrite(ticket.id, message, extra_sig=self.get_url(ticket))
     
     def ticket_deleted(self, ticket):
         message = "%s deleted ticket %d" % (author, ticket.id)
-        self.zwrite(ticket.id, message)
+        self.zwrite(ticket.id, message, extra_sig=self.get_url(ticket))
index 67634c71bb5c6225c73126d3a87c8af5bc3671fb..75e33d0d5d1ca1b49460fd76017a78e71319cbee 100755 (executable)
@@ -4,9 +4,9 @@ from setuptools import find_packages, setup
 
 setup(
     name='TracZephyrPlugin',
-    version='1.4.1',
-    author='Evan Broder',
-    author_email='broder@mit.edu',
+    version='1.4.2',
+    author='Evan Broder and the SIPB Snippets team',
+    author_email='snippets@mit.edu',
     description='Send a zephyr when a Trac ticket is created or updated',
     py_modules=["ZephyrPlugin"],
     entry_points = """