summaryrefslogtreecommitdiff
path: root/git-dch
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2008-08-15 12:33:48 +0200
committerGuido Guenther <agx@sigxcpu.org>2008-08-15 14:28:21 +0200
commitd1ea39df0e937416bcdbe34f86b98a87716541ca (patch)
tree29052b15225b2d8eb9e95dbfd189e7f631418d6b /git-dch
parentd9ea64bd6dfec7750546c6515c477316be9efeaa (diff)
downloadgit-buildpackage-d1ea39df0e937416bcdbe34f86b98a87716541ca.tar.gz
git-buildpackage-d1ea39df0e937416bcdbe34f86b98a87716541ca.tar.bz2
git-buildpackage-d1ea39df0e937416bcdbe34f86b98a87716541ca.zip
allow setting the bug-closing meta tag to look for
this way we can generate bug-closing entries for different BTSs such as Debian or Launchpad.
Diffstat (limited to 'git-dch')
-rwxr-xr-xgit-dch22
1 files changed, 16 insertions, 6 deletions
diff --git a/git-dch b/git-dch
index d0dad92b..ea732eb5 100755
--- a/git-dch
+++ b/git-dch
@@ -154,12 +154,15 @@ def get_author(commit):
return m.group('author'), m.group('email')
+
def parse_commit(repo, commitid, options):
"""parse a commit and return message and author"""
msg = ''
thanks = ''
closes = ''
- bugs = []
+ bugs = {}
+ bts_closes = re.compile(r'(?P<bts>%s):\s+#[0-9]+' % options.meta_closes)
+ bts_bug = re.compile(r'#[0-9]+')
commit = repo.show(commitid)
author, email = get_author(commit)
@@ -168,8 +171,13 @@ def parse_commit(repo, commitid, options):
for line in commit:
if line.startswith(' '): # commit body
line = line[4:]
- if line.startswith('Closes: '):
- bugs += [ line.split(' ', 1)[1].strip() ]
+ m = bts_closes.match(line)
+ if m:
+ nums = bts_bug.findall(line)
+ try:
+ bugs[m.group('bts')] += nums
+ except KeyError:
+ bugs[m.group('bts')] = nums
elif line.startswith('Thanks: '):
thanks = line.split(' ', 1)[1].strip()
else: # normal commit message
@@ -181,10 +189,10 @@ def parse_commit(repo, commitid, options):
elif line.startswith('diff '):
break
if options.meta:
- if bugs:
- closes = '(Closes: %s)' % ', '.join(bugs)
+ for bts in bugs:
+ closes += '(%s: %s) ' % (bts, ', '.join(bugs[bts]))
if thanks:
- thanks = ' - thanks to %s' % thanks
+ thanks = '- thanks to %s' % thanks
msg += closes + thanks
if options.idlen:
msg = "[%s] " % commitid[0:options.idlen] + msg
@@ -243,6 +251,8 @@ def main(argv):
help="mark as snapshot build")
commit_group.add_config_file_option(option_name="meta", dest="meta",
help="parse meta tags in commit messages, default is '%(meta)s'", action="store_true")
+ commit_group.add_config_file_option(option_name="meta-closes", dest="meta_closes",
+ help="Meta tags for the bts close commands, default is '%(meta-closes)s'")
commit_group.add_option("--full", action="store_false", dest="short", default=True,
help="include the full commit message instead of only the first line")
commit_group.add_config_file_option(option_name="id-length", dest="idlen",