From: Alec Warner <antarus@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: Re: [gentoo-portage-dev] [PATCH] repoman commit: Support --bug (-b) and --closes (-c) for git footer
Date: Thu, 3 Aug 2017 11:18:36 -0400 [thread overview]
Message-ID: <CAAr7Pr8fa2zBoctgHpfaaV9qyRgYqMVohr=rozUNA1fkwccV3Q@mail.gmail.com> (raw)
In-Reply-To: <20170803141826.22533-1-mgorny@gentoo.org>
[-- Attachment #1: Type: text/plain, Size: 5421 bytes --]
On Thu, Aug 3, 2017 at 10:18 AM, Michał Górny <mgorny@gentoo.org> wrote:
> Support two new options: --bug (-b) and --closes (-c) to add a plain
> 'Bug' reference and a 'Closes' footer for a GitHub pull request. Both
> options can be specified multiple times, resulting in multiple footer
> tags being written.
>
> The --bug option accepts either a Gentoo Bugzilla bug number or an URL
> to any bug tracker. In the latter case, it performs two trivial
> transformations automatically: replaces long 'show_bug.cgi' Bugzilla
> URLs with the short 'https://bugs.gentoo.org/NNNNNN', and forces
> https:// for a few known services.
>
> The --closes option accepts either a GitHub Gentoo repository pull
> request number or an URL to any pull request (or bug) that uses
> the 'Closes' tag. In the latter case, https:// is forced for a few known
> services.
> ---
> repoman/pym/repoman/actions.py | 29 +++++++++++++++++++++++++++++
> repoman/pym/repoman/argparser.py | 16 +++++++++++++++-
> 2 files changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/repoman/pym/repoman/actions.py b/repoman/pym/repoman/actions.
> py
> index 00bb5b2ca..869ca7031 100644
> --- a/repoman/pym/repoman/actions.py
> +++ b/repoman/pym/repoman/actions.py
> @@ -324,6 +324,11 @@ class Actions(object):
> return (changes.new, changes.changed, changes.removed,
> changes.no_expansion, changes.expansion)
>
> + long_bugzilla_url_re = re.compile(
> + r'https?://bugs\.gentoo\.org/
> show_bug\.cgi\?id=(\d+(#.*)?)')
> + http_bugtracker_url_re = re.compile(
> + r'http://(bugs\.gentoo\.org|bitbucket\.org|git(hub|lab)\.
> com)/')
> +
>
Would you consider using the urlparse module here, instead of regexp?
> def get_commit_footer(self):
> portage_version = getattr(portage, "VERSION", None)
> gpg_key = self.repoman_settings.get("PORTAGE_GPG_KEY", "")
> @@ -345,6 +350,30 @@ class Actions(object):
>
> # Common part of commit footer
> commit_footer = "\n"
> + for bug in self.options.bug:
> + # case 1: pure number NNNNNN
> + if bug.isdigit():
> + bug = 'https://bugs.gentoo.org/%s' %
> (bug, )
> + else:
> + # case 2: long Gentoo bugzilla URL to
> shorten
> + m = self.long_bugzilla_url_re.match(bug)
> + if m is not None:
> + bug = 'https://bugs.gentoo.org/%s'
> % (m.group(1), )
> + # case 3: bug tracker w/ http -> https
> + m = self.http_bugtracker_url_re.match(bug)
> + if m is not None:
> + bug = bug.replace('http', 'https',
> 1)
> + commit_footer += "Bug: %s\n" % (bug, )
> + for closes in self.options.closes:
> + # case 1: pure number NNNN
> + if closes.isdigit():
> + closes = 'https://github.com/gentoo/
> gentoo/pull/%s' % (closes, )
> + else:
> + # case 2: bug tracker w/ http -> https
> + m = self.http_bugtracker_url_re.
> match(closes)
> + if m is not None:
> + closes = closes.replace('http',
> 'https', 1)
> + commit_footer += "Closes: %s\n" % (closes, )
> if dco_sob:
> commit_footer += "Signed-off-by: %s\n" % (dco_sob,
> )
>
> diff --git a/repoman/pym/repoman/argparser.py b/repoman/pym/repoman/
> argparser.py
> index 2d56a87e6..f32972288 100644
> --- a/repoman/pym/repoman/argparser.py
> +++ b/repoman/pym/repoman/argparser.py
> @@ -1,5 +1,5 @@
> # repoman: Argument parser
> -# Copyright 2007-2014 Gentoo Foundation
> +# Copyright 2007-2017 Gentoo Foundation
> # Distributed under the terms of the GNU General Public License v2
>
> """This module contains functions used in Repoman to parse CLI
> arguments."""
> @@ -58,6 +58,20 @@ def parse_args(argv, qahelp, repoman_default_opts):
> help='Request a confirmation before commiting')
>
> parser.add_argument(
> + '-b', '--bug', dest='bug', action='append',
> metavar='<BUG-NO|BUG-URL>',
> + default=[],
> + help=(
> + 'Mention a Gentoo or upstream bug in the commit
> footer; '
> + 'takes either Gentoo bug number or full bug URL'))
> +
> + parser.add_argument(
> + '-c', '--closes', dest='closes', action='append',
> metavar='<PR-NO|PR-URL>',
> + default=[],
> + help=(
> + 'Adds a Closes footer to close GitHub pull request
> (or compatible); '
> + 'takes either GitHub PR number or full PR URL'))
> +
> + parser.add_argument(
> '-m', '--commitmsg', dest='commitmsg',
> help='specify a commit message on the command line')
>
> --
> 2.13.4
>
>
>
[-- Attachment #2: Type: text/html, Size: 7455 bytes --]
next prev parent reply other threads:[~2017-08-03 15:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-03 14:18 [gentoo-portage-dev] [PATCH] repoman commit: Support --bug (-b) and --closes (-c) for git footer Michał Górny
2017-08-03 15:18 ` Alec Warner [this message]
2017-08-03 16:15 ` Michał Górny
2017-08-03 16:26 ` Alec Warner
2017-08-04 22:37 ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
2017-08-05 21:11 ` Alec Warner
2017-08-05 21:22 ` Michał Górny
2017-08-05 21:26 ` [gentoo-portage-dev] [PATCH v3] " Michał Górny
2017-08-06 5:53 ` Zac Medico
2017-08-06 6:53 ` [gentoo-portage-dev] [PATCH v4] " Michał Górny
2017-08-06 7:18 ` Zac Medico
2017-08-06 10:28 ` Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAr7Pr8fa2zBoctgHpfaaV9qyRgYqMVohr=rozUNA1fkwccV3Q@mail.gmail.com' \
--to=antarus@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
--cc=mgorny@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox