summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/manpages/gbp-rpm-ch.sgml21
-rw-r--r--gbp/config.py3
-rw-r--r--gbp/rpm/policy.py15
-rwxr-xr-xgbp/scripts/rpm_ch.py4
-rw-r--r--tests/component/rpm/test_rpm_ch.py20
5 files changed, 53 insertions, 10 deletions
diff --git a/docs/manpages/gbp-rpm-ch.sgml b/docs/manpages/gbp-rpm-ch.sgml
index 59adaa5a..fbd28967 100644
--- a/docs/manpages/gbp-rpm-ch.sgml
+++ b/docs/manpages/gbp-rpm-ch.sgml
@@ -33,6 +33,7 @@
<arg><option>--message=</option><replaceable>MESSAGE</replaceable></arg>
<arg><option>--since=</option><replaceable>COMMITISH</replaceable></arg>
</group>
+ <arg><option>--meta-bts=</option><replaceable>META_TAGS</replaceable></arg>
<arg><option>--no-release</option></arg>
<arg><option>--[no-]git-author</option></arg>
<arg><option>--[no-]full</option></arg>
@@ -171,6 +172,19 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>--meta-bts=</option><replaceable>META_TAGS</replaceable>
+ </term>
+ <listitem>
+ <para>
+ Meta tags in the commit messages that are interpreted as bug tracking
+ system related references. The recognized bts references are added in
+ the generated changelog entries. See the META TAGS section below for
+ more information. The bts meta tag tracking feature can be disabled
+ by defining an empty string.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--no-release</option>
</term>
<listitem>
@@ -378,11 +392,14 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><option>[Close|Closes|Fix|Fixes]</option>: <replaceable>BUGNUMBER</replaceable>
+ <term><option>[Close|Closes|...]</option>: <replaceable>BUGNUMBER</replaceable>
</term>
<listitem>
<para>
- Indicate in the changelog that the bug was addressed by this commit.
+ Indicate in the changelog entry that bug
+ <replaceable>BUGNUMBER</replaceable> was addressed in this commit.
+ The bts meta tags recognized by &gbp-rpm-ch; is actually defined by
+ the <option>--meta-bts</option> option.
</para>
</listitem>
</varlistentry>
diff --git a/gbp/config.py b/gbp/config.py
index 6f251a46..983c5ef9 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -624,6 +624,7 @@ class GbpOptionParserRpm(GbpOptionParser):
'changelog-revision' : '',
'spawn-editor' : 'always',
'editor-cmd' : 'vim',
+ 'meta-bts' : '(Close|Closes|Fixes|Fix)',
})
help = dict(GbpOptionParser.help)
@@ -694,6 +695,8 @@ class GbpOptionParserRpm(GbpOptionParser):
'git-author':
"Use name and email from git-config for the changelog header, "
"default is '%(git-author)s'",
+ 'meta-bts':
+ "Meta tags for the bts commands, default is '%(meta-bts)s'",
})
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/gbp/rpm/policy.py b/gbp/rpm/policy.py
index 82d6abee..9fae0457 100644
--- a/gbp/rpm/policy.py
+++ b/gbp/rpm/policy.py
@@ -167,8 +167,6 @@ class RpmPkgPolicy(PkgPolicy):
# Maximum length for a changelog entry line
max_entry_line_length = 76
- # Bug tracking system related meta tags recognized from git commit msg
- bts_meta_tags = ("Close", "Closes", "Fixes", "Fix")
# Regexp for matching bug tracking system ids (e.g. "bgo#123")
bug_id_re = r'[A-Za-z0-9#_\-]+'
@@ -180,15 +178,18 @@ class RpmPkgPolicy(PkgPolicy):
@param lines: commit message
@type lines: C{list} of C{str}
- @param meta_tags: meta tags to look for
- @type meta_tags: C{tuple} of C{str}
+ @param meta_tags: meta tags (regexp) to look for
+ @type meta_tags: C{str}
@return: bts-ids per meta tag and the non-mathced lines
@rtype: (C{dict}, C{list} of C{str})
"""
+ if not meta_tags:
+ return ({}, lines[:])
+
tags = {}
other_lines = []
- bts_re = re.compile(r'^(?P<tag>%s):\s*(?P<ids>.*)' %
- ('|'.join(meta_tags)), re.I)
+ bts_re = re.compile(r'^(?P<tag>%s):\s*(?P<ids>.*)' % meta_tags,
+ re.I)
bug_id_re = re.compile(cls.bug_id_re)
for line in lines:
match = bts_re.match(line)
@@ -244,7 +245,7 @@ class RpmPkgPolicy(PkgPolicy):
return None
# Parse and filter out bts-related meta-tags
- bts_tags, body = cls._parse_bts_tags(body, cls.bts_meta_tags)
+ bts_tags, body = cls._parse_bts_tags(body, kwargs['meta_bts'])
# Additional filtering
body = cls._extra_filter(body, kwargs['ignore_re'])
diff --git a/gbp/scripts/rpm_ch.py b/gbp/scripts/rpm_ch.py
index 3caaac2e..33058372 100755
--- a/gbp/scripts/rpm_ch.py
+++ b/gbp/scripts/rpm_ch.py
@@ -279,7 +279,8 @@ def entries_from_commits(changelog, repo, commits, options):
for commit in commits:
info = repo.get_commit_info(commit)
entry_text = ChangelogEntryFormatter.compose(info, full=options.full,
- ignore_re=options.ignore_regex, id_len=options.idlen)
+ ignore_re=options.ignore_regex, id_len=options.idlen,
+ meta_bts=options.meta_bts)
if entry_text:
entries.append(changelog.create_entry(author=info['author'].name,
text=entry_text))
@@ -431,6 +432,7 @@ def parse_args(argv):
help="use all commits from the Git history, overrides "
"--since")
# Formatting group options
+ format_grp.add_config_file_option(option_name="meta-bts", dest="meta_bts")
format_grp.add_option("--no-release", action="store_false", default=True,
dest="release",
help="no release, just update the last changelog section")
diff --git a/tests/component/rpm/test_rpm_ch.py b/tests/component/rpm/test_rpm_ch.py
index b69c517e..db03c845 100644
--- a/tests/component/rpm/test_rpm_ch.py
+++ b/tests/component/rpm/test_rpm_ch.py
@@ -181,6 +181,26 @@ class TestRpmCh(RpmRepoTestBase):
eq_(mock_ch(['--packaging-branch=foo', '--ignore-branch']), 0)
+ def test_option_meta_bts(self):
+ """Test parsing of the bts meta tags"""
+ repo = self.init_test_repo('gbp-test-native')
+
+ # Create a dummy commit that references bts
+ with open('new-file', 'w') as fobj:
+ fobj.write('foobar\n')
+ repo.add_files('new-file')
+ repo.commit_all('Fix\n\nCloses: #123\nFixes: #456\n Fixes: #789')
+
+ eq_(mock_ch(['--since=HEAD^']), 0)
+ content = self.read_file('packaging/gbp-test-native.changes')
+ # rpm-ch shouldn't have picked the ref with leading whitespace
+ eq_(content[1], '- Fix (Closes: #123) (Fixes: #456)\n')
+
+ # Check the --meta-bts option
+ eq_(mock_ch(['--since=HEAD^', '--meta-bts=Fixes']), 0)
+ content = self.read_file('packaging/gbp-test-native.changes')
+ eq_(content[1], '- Fix (Fixes: #456)\n')
+
def test_option_no_release(self):
"""Test the --no-release cmdline option"""
self.init_test_repo('gbp-test-native')