diff options
author | Guido Guenther <agx@sigxcpu.org> | 2008-08-15 12:33:48 +0200 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2008-08-15 14:28:21 +0200 |
commit | d1ea39df0e937416bcdbe34f86b98a87716541ca (patch) | |
tree | 29052b15225b2d8eb9e95dbfd189e7f631418d6b | |
parent | d9ea64bd6dfec7750546c6515c477316be9efeaa (diff) | |
download | git-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.
-rw-r--r-- | gbp/config.py | 1 | ||||
-rwxr-xr-x | git-dch | 22 |
2 files changed, 17 insertions, 6 deletions
diff --git a/gbp/config.py b/gbp/config.py index b4d7d2e8..c915c99c 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -41,6 +41,7 @@ class GbpOptionParser(OptionParser): 'tarball-dir' : '', 'ignore-new' : 'False', 'meta' : 'False', + 'meta-closes' : 'Closes|LP', 'id-length' : '0', 'no-dch' : 'False', } @@ -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", |