From eeb9e111fd05fbf3042d296eef074d07eb34a362 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Thu, 2 Jan 2014 16:32:37 -0500 Subject: [PATCH] Separate handling of ChangeIds and Git SHAs in Gerrit Since Ia337ddfe2ddc82c858072135a613786070f0dc67, ChangeIds not surrounded by whitespace (such as that one) are no longer turned into links. (It also reduces the minimum length of a hex string required to recognise a ChangeId from 8 to 7 for reasons that are undocumented, and therefore suspect.) The purpose of that patch was to prevent overzealous matching of strings in e.g. URLs as possible ChangeIds. This stems from I5cd74bef5510c8dbf3891dcfa3086a141e445f0d, which extended the changeid regex to also look for Git SHA hashes, which are far more likely to show up as false positives. In fact, Ia337ddfe2ddc82c858072135a613786070f0dc67 actually destroys the original rationale of I5cd74bef5510c8dbf3891dcfa3086a141e445f0d by refusing to match SHAs that are followed by a closing parenthesis, as cherry-picked commits on stable branches are. This patch makes the following changes: * Separates the changeid and gitsha commentlink handlers * Restores the changeid patterns to their original values * Matches only full Git SHAs (not just all 8+ character hex strings) * Allows for other common punctuation around Git SHAs (commas, colons, semicolons, parentheses). Fixes bug 1265646 Change-Id: I0844ee2fd8d8699059eb7afa92b282cf5b890c18 --- modules/openstack_project/manifests/gerrit.pp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/openstack_project/manifests/gerrit.pp b/modules/openstack_project/manifests/gerrit.pp index 33e0394c0c..fa392df7c6 100644 --- a/modules/openstack_project/manifests/gerrit.pp +++ b/modules/openstack_project/manifests/gerrit.pp @@ -153,7 +153,12 @@ class openstack_project::gerrit ( }, { name => 'changeid', - match => '(

|[\\s]+)(I?[0-9a-f]{7,40})(

|[\\s.]+)', + match => 'I[0-9a-f]{8,40}', + link => '#q,$1,n,z', + }, + { + name => 'gitsha', + match => '(

|[\\s(])([0-9a-f]{40})(

|[\\s.,;:)])', html => '$1$2$3', }, ],