]> andersk Git - zcommit.git/blobdiff - zcommit.py
Tweak the Zephyr formatting.
[zcommit.git] / zcommit.py
index 0fae9fe6dfeed73e14218e4ede2bc359dd2be820..ed11afb7b3cf2a3c38836bce19023656c0a45803 100755 (executable)
@@ -8,6 +8,7 @@ import os
 import subprocess
 import sys
 import traceback
+import dateutil.parser
 
 HERE = os.path.abspath(os.path.dirname(__file__))
 ZWRITE = os.path.join(HERE, 'bin', 'zsend')
@@ -35,7 +36,7 @@ msg: %(msg)s""" % {'sender' : sender,
                    'msg' : msg})
     cmd = [ZWRITE, '-S', sender, '-c', klass, '-i', instance,
            '-s', zsig, '-d', '-m', msg]
-    subprocess.check_call(cmd)
+    subprocess.check_call([p.encode('utf-8') for p in cmd])
 
 class Application(object):
     @cherrypy.expose
@@ -69,7 +70,7 @@ any of the following optional key/value parameters:
 
 <ul>
 <li> <tt>/instance/$instance</tt> </li>
-<li> <tt>/zsig/$zsig</tt> </li>
+<li> <tt>/zsig/$zsig</tt> (sets the prefix of the zsig; the postfix is always the branch name) </li>
 <li> <tt>/sender/$sender</tt> </li>
 </ul>
 """
@@ -91,7 +92,7 @@ any of the following optional key/value parameters:
                 raise cherrypy.HTTPError(400, 'Invalid submission URL')
             logger.debug('Passed validation')
             for i in xrange(0, len(args), 2):
-                opts[args[i]] = args[i + 1]
+                opts[args[i]] = unicode(args[i + 1], 'utf-8', 'replace')
             logger.debug('Set opts')
             if 'class' not in opts:
                 raise cherrypy.HTTPError(400, 'Must specify a zephyr class name')
@@ -105,28 +106,30 @@ any of the following optional key/value parameters:
                     zsig = '%s: %s' % (opts['zsig'], zsig)
                 sender = opts.get('sender', 'daemon.zcommit')
                 logger.debug('Set zsig')
-                for c in reversed(payload['commits']):
+                for c in payload['commits']:
                     inst = opts.get('instance', c['id'][:8])
                     actions = []
                     if c.get('added'):
-                        actions.append('Added: %s\n' % '\n  '.join(c['added']))
+                        actions.extend('  A %s\n' % f for f in c['added'])
                     if c.get('removed'):
-                        actions.append('Removed: %s\n' % '\n  '.join(c['removed']))
+                        actions.extend('  D %s\n' % f for f in c['removed'])
                     if c.get('modified'):
-                        actions.append('Modified: %s\n' % '\n  '.join(c['modified']))
+                        actions.extend('  M %s\n' % f for f in c['modified'])
                     if not actions:
                         actions.append('Did not add/remove/modify any nonempty files.')
                     info = {'name' : c['author']['name'],
                             'email' : c['author']['email'],
                             'message' : c['message'],
-                            'timestamp' : c['timestamp'],
-                            'actions' : '--\n'.join(actions),
+                            'timestamp' : dateutil.parser.parse(c['timestamp']).strftime('%F %T %z'),
+                            'actions' : ''.join(actions),
                             'url' : c['url']}
                     
-                    msg = """%(name)s <%(email)s> (%(timestamp)s)
-%(url)s
-> %(message)s
---
+                    msg = """%(url)s
+Author: %(name)s <%(email)s>
+Date:   %(timestamp)s
+
+%(message)s
+---
 %(actions)s""" % info
                     zephyr(sender, opts['class'], inst, zsig, msg)
                 msg = 'Thanks for posting!'
This page took 0.273363 seconds and 4 git commands to generate.