[git-buildpackage] [PATCH master] gbp-dch: allow bug number format to be overridden

Guido Günther agx at sigxcpu.org
Wed Aug 26 09:31:30 CEST 2015


Hi,

Thanks for the patch.

On Mon, Aug 24, 2015 at 10:35:52AM -0400, Jonathan Toppins wrote:
> Some derivatives and non Debian exclusive projects don't use just
> numbers for their bug numbers. gbp-dch should still be able to parse
> these bug numbers and generate useful changelog entries. This doesn't
> solve dpkg-parsechangelog but is a start.
> 
> 	Examples of non-Debian bug numbers are:
> 		example change header
> 
> 		Example: EX-12345
> 
> 	Should produce the following change log:
> 		* example change header (Example: EX-12345)
> 
> This also helps in pulling CVE numbers simply by letting the user
> modify the regex to something like 'cve-\d+-\d+'.

This is basically fine but
* --meta-bugnumfmt is a strange name, we don't usually have a "fmt" at
  the end (e.g. --meta-closes instead of --meta-closes-fmt. What about
  --meta-closes-bugnum ? It's a but long but is builds a relation to the
  --meta-closes tag ?
* Please add some tests. This is getting complex enough to warrant
  e.g. some doctests in a separate file.

Some minor nits inline below

> 
> Signed-off-by: Jonathan Toppins <jtoppins at cumulusnetworks.com>
> ---
>  Note: please keep me on the CC list as I am not subscribed to the mailing list.
> 
>  debian/git-buildpackage.zsh-completion |  2 ++
>  docs/manpages/gbp-dch.sgml             | 13 +++++++++++++
>  gbp.conf                               |  2 ++
>  gbp/config.py                          |  3 +++
>  gbp/dch.py                             |  7 ++-----
>  gbp/scripts/dch.py                     |  1 +
>  6 files changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/debian/git-buildpackage.zsh-completion b/debian/git-buildpackage.zsh-completion
> index 1fc843e..a95beef 100644
> --- a/debian/git-buildpackage.zsh-completion
> +++ b/debian/git-buildpackage.zsh-completion
> @@ -137,6 +137,7 @@ _gbp-dch () {
>  		'(--meta --no-meta)--meta[Parse meta tags]' \
>  		'(--meta --no-meta)--no-meta[Do not parse meta tags]' \
>  		'--meta-closes=-[What meta tags to look for  to  generate  bug-closing  changelog entries]' \
> +		'--meta-bugnumfmt=-[What bug number format to look for to generate bug-closing changelog entries]' \
>  		'(--full --no-full)--full[Include the full commit message]' \
>  		'(--full --no-full)--no-full[Do not include the full commit message]' \
>  		'(--snapshot -S)'{-S,--snapshot}'[Create a snapshot release entry]' \
> @@ -381,6 +382,7 @@ _gbp-dch () {
>  		'(--meta --no-meta)--meta[Parse meta tags]' \
>  		'(--meta --no-meta)--no-meta[Do not parse meta tags]' \
>  		'--meta-closes=-[What meta tags to look for  to  generate  bug-closing  changelog entries]' \
> +		'--meta-bugnumfmt=-[What bug number format to look for to generate bug-closing changelog entries]' \
>  		'(--full --no-full)--full[Include the full commit message]' \
>  		'(--full --no-full)--no-full[Do not include the full commit message]' \
>  		'(--snapshot -S)'{-S,--snapshot}'[Create a snapshot release entry]' \
> diff --git a/docs/manpages/gbp-dch.sgml b/docs/manpages/gbp-dch.sgml
> index 888d987..8e02c50 100644
> --- a/docs/manpages/gbp-dch.sgml
> +++ b/docs/manpages/gbp-dch.sgml
> @@ -46,6 +46,7 @@
>        <arg><option>--[no-]full</option></arg>
>        <arg><option>--[no-]meta</option></arg>
>        <arg><option>--meta-closes=bug-close-tags</option></arg>
> +      <arg><option>--meta-bugnumfmt=bug-number-format</option></arg>
>        <arg><option>--snapshot-number=</option><replaceable>expression</replaceable></arg>
>        <arg><option>--id-length=</option><replaceable>number</replaceable></arg>
>        <arg><option>--git-log=</option><replaceable>git-log-options</replaceable></arg>
> @@ -183,6 +184,18 @@
>          </listitem>
>        </varlistentry>
>        <varlistentry>
> +        <term><option>--meta-bugnumfmt=</option><replaceable>bug-number-format</replaceable>
> +        </term>
> +        <listitem>
> +          <para>
> +          What regular expression should be used for parse out the bug number.

s/for/to/

> +          The default is '(?:bug|issue)?\#?\s?\d+'. Note: the regex should
> +          suppress all portions of the bug number that are not wanted using
> +          "(?:)", see pyhton regex manual for details.

Please give an example here.

> +          </para>
> +        </listitem>
> +      </varlistentry>
> +      <varlistentry>
>          <term><option>--[no-]full</option>
>          </term>
>          <listitem>
> diff --git a/gbp.conf b/gbp.conf
> index 43fc36d..222656b 100644
> --- a/gbp.conf
> +++ b/gbp.conf
> @@ -96,6 +96,8 @@
>  #meta = False
>  # what tags to look for to generate bug-closing changelog entries:
>  #meta-closes = Closes|LP
> +# what regex should be used to parse the bug number
> +#meta-bugnumfmt = '(?:bug|issue)?\#?\s?\d+'
>  # include the full commit message in the changelog:
>  #full = True
>  # ignore Signed-off-by: lines:
> diff --git a/gbp/config.py b/gbp/config.py
> index 3b483c0..afbd2c4 100644
> --- a/gbp/config.py
> +++ b/gbp/config.py
> @@ -125,6 +125,7 @@ class GbpOptionParser(OptionParser):
>                   'ignore-branch'   : 'False',
>                   'meta'            : 'True',
>                   'meta-closes'     : 'Closes|LP',
> +                 'meta-bugnumfmt'  : r'(?:bug|issue)?\#?\s?\d+',
>                   'full'            : 'False',
>                   'id-length'       : '0',
>                   'git-author'      : 'False',
> @@ -212,6 +213,8 @@ class GbpOptionParser(OptionParser):
>                    "Parse meta tags in commit messages, default is '%(meta)s'",
>               'meta-closes':
>                    "Meta tags for the bts close commands, default is '%(meta-closes)s'",
> +             'meta-bugnumfmt':
> +                  "Meta bug number format, default is '%(meta-bugnumfmt)s'",
>               'ignore-new':
>                    "Build with uncommited changes in the source tree, default is '%(ignore-new)s'",
>               'ignore-branch':
> diff --git a/gbp/dch.py b/gbp/dch.py
> index 49b1020..c092c28 100644
> --- a/gbp/dch.py
> +++ b/gbp/dch.py
> @@ -45,17 +45,14 @@ def filter_ignore_rx_matches(lines, options):
>      else:
>          return lines
>  
> -
> -_bug_r = r'(?:bug|issue)?\#?\s?\d+'
> -_bug_re = re.compile(_bug_r, re.I)
> -
>  def extract_bts_cmds(lines, opts):
>      """Return a dictionary of the bug tracking system commands
>      contained in the the given lines.  i.e. {'closed' : [1], 'fixed':
>      [3, 4]}.  Right now, this will only notice a single directive
>      clause on a line.  Also return all of the lines that do not
>      contain bug tracking system commands."""
> -    bts_rx = re.compile(r'(?P<bts>%s):\s+%s' % (opts.meta_closes, _bug_r), re.I)
> +    _bug_re = re.compile(opts.meta_bugnumfmt, re.I)
> +    bts_rx = re.compile(r'(?P<bts>%s):\s+%s' % (opts.meta_closes, opts.meta_bugnumfmt), re.I)
>      commands = {}
>      other_lines = []
>      for line in lines:
> diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
> index e3f7c7c..cbd66ea 100644
> --- a/gbp/scripts/dch.py
> +++ b/gbp/scripts/dch.py
> @@ -358,6 +358,7 @@ def build_parser(name):
>      version_group.add_boolean_config_file_option(option_name="git-author", dest="use_git_author")
>      commit_group.add_boolean_config_file_option(option_name="meta", dest="meta")
>      commit_group.add_config_file_option(option_name="meta-closes", dest="meta_closes")
> +    commit_group.add_config_file_option(option_name="meta-bugnumfmt", dest="meta_bugnumfmt")
>      commit_group.add_boolean_config_file_option(option_name="full", dest="full")
>      commit_group.add_config_file_option(option_name="id-length", dest="idlen",
>                        help="include N digits of the commit id in the changelog entry, default is '%(id-length)s'",
> -- 

Cheers,
 -- Guido


More information about the git-buildpackage mailing list