From c660e1ad48ba4763209bf3c32b71a11a62d8b607 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Thu, 15 Apr 2010 11:27:23 +0200 Subject: [PATCH] add newscommit --- cleanpg | 2 +- newscommit | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 newscommit diff --git a/cleanpg b/cleanpg index e238f18..3719c34 100755 --- a/cleanpg +++ b/cleanpg @@ -5,4 +5,4 @@ for v in 7.4 8.0 8.1 8.2 8.3; do [ -x $i ] && $SUDO $i stop done $SUDO killall pg_autovacuum postmaster postgres -$SUDO rm -rf /etc/postgresql /var/lib/postgresql/ /var/log/postgresql/ /tmp/postgresql-testsuite/ /var/run/postgresql/* +$SUDO rm -rf /etc/postgresql /var/lib/postgresql/ /var/log/postgresql/* /tmp/postgresql-testsuite/ /var/run/postgresql/* diff --git a/newscommit b/newscommit new file mode 100755 index 0000000..b1d8b51 --- /dev/null +++ b/newscommit @@ -0,0 +1,46 @@ +#!/usr/bin/python + +import subprocess, re, sys + +lpbugs_re = re.compile(r'lp: #([0-9, ]+)', re.I) + +bzr = subprocess.Popen(['bzr', 'diff', 'NEWS'], stdout=subprocess.PIPE) +raw_msg = bzr.communicate()[0].strip() +if bzr.returncode != 1: + print >> sys.stderr, 'bzr diff NEWS failed' + sys.exit(1) + +# parse/format message +msg = '' +for l in raw_msg.splitlines(): + if not l.startswith('+ '): + continue + if msg: + msg += ' ' + msg += l[2:].strip() + +if msg.startswith('-'): + msg = msg[1:].strip() + +print '-- commit message: --' +print msg +print '---' + +if not msg: + print >> sys.stderr, 'No message in NEWS, aborting' + sys.exit(1) + +# parse Launchpad bugs +lpbugs = [] +for b_grp in lpbugs_re.finditer(msg): + for b in b_grp.group(1).split(','): + lpbugs.append(b.strip()) +print 'Fixed LP bugs:', ' '.join(lpbugs) + +# commit +argv = ['bzr', 'commit', '-m', msg] +for b in lpbugs: + argv += ['--fixes', 'lp:' + b] + +sys.exit(subprocess.call(argv)) + -- 2.39.2