X-Git-Url: https://piware.de/gitweb/?p=bin.git;a=blobdiff_plain;f=newscommit;fp=newscommit;h=b1d8b5117d9feb17987af4ec7a07e7ee7e2eed96;hp=0000000000000000000000000000000000000000;hb=c660e1ad48ba4763209bf3c32b71a11a62d8b607;hpb=8dc8587c1ffe2ca9bfd199ae322240db59eb748b 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)) +