From d1cdbd4aae4a274ace27f48b8dba67a006e338e1 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 24 Sep 2013 17:45:08 +0000 Subject: [PATCH] Limit bug links in Gerrit to recommended headers Per https://wiki.openstack.org/wiki/GitCommitMessages the recommended commit message headers for bug links are: Closes-Bug: #1234567 Partial-Bug: #1234567 Related-Bug: #1234567 This change limits the bug-specific Gerrit commentlink to only match on the above three patterns, potentially all-lower-case, space and pound sign optional. It should help to train developers to apply these with greater consistency in their commits. Also support "(start-of-word)bug:? #?\d+" separately, so that bugs mentioned loosely in the commit message, reviews or inline code comments will still get hyperlinked. This latter pattern does leave some ambiguity in commit messages, however, as developers might think their bug will get updated when they add old-style lines like "Fixes bug 1234567" instead of a .*-bug header, because both get the same hyperlinks. Change-Id: I57fa0ca901a7228dc0739fdd98ff12aa091f0dbe --- modules/openstack_project/manifests/gerrit.pp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/openstack_project/manifests/gerrit.pp b/modules/openstack_project/manifests/gerrit.pp index 428ad91328..e62aed2f44 100644 --- a/modules/openstack_project/manifests/gerrit.pp +++ b/modules/openstack_project/manifests/gerrit.pp @@ -130,9 +130,14 @@ class openstack_project::gerrit ( link => '#q,$1,n,z', }, { - name => 'launchpad', - match => '(\\b[Bb]ug\\b|\\b[Ll][Pp]\\b)[ \\t#:]*(\\d+)', - link => 'https://code.launchpad.net/bugs/$2', + name => 'bugheader', + match => '^([Cc]loses|[Pp]artial|[Rr]elated)-[Bb]ug:[\\s#]?(\\d+)$', + link => 'https://launchpad.net/bugs/$2', + }, + { + name => 'bug', + match => '\\bbug:? #?(\\d+)', + link => 'https://launchpad.net/bugs/$1', }, { name => 'blueprint',