summaryrefslogtreecommitdiffstats
path: root/extensions/BMO
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2014-04-23 22:18:07 +0200
committerDylan William Hardison <dylan@hardison.net>2014-04-28 09:50:56 +0200
commit4543712ebd6346c76be92893ebe22c3908271a4a (patch)
tree27b8468246a0ea8664734f32a0079cdd7c1b2eee /extensions/BMO
parentb2eb6004e7caa17a8f4a1d7c99674550cfda19dc (diff)
downloadbugzilla-4543712ebd6346c76be92893ebe22c3908271a4a.tar.gz
bugzilla-4543712ebd6346c76be92893ebe22c3908271a4a.tar.xz
Bug 999668 - We don't linkify the alternative ssh remote syntax
r=glob
Diffstat (limited to 'extensions/BMO')
-rw-r--r--extensions/BMO/Extension.pm2
-rwxr-xr-xextensions/BMO/t/bug_format_comment.t79
2 files changed, 80 insertions, 1 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index f3e31e10a..87c49ef95 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -482,7 +482,7 @@ sub bug_format_comment {
# link git.mozilla.org commit messages
push (@$regexes, {
- match => qr#^(To\sssh://[^\@]+\@git\.mozilla\.org\/(.+?.git)\n
+ match => qr#^(To\s(?:ssh://)?[^\@]+\@git\.mozilla\.org[:/](.+?\.git)\n
\s+)([0-9a-z]+\.\.([0-9a-z]+)\s+\S+\s->\s\S+)#mx,
replace => sub {
my $args = shift;
diff --git a/extensions/BMO/t/bug_format_comment.t b/extensions/BMO/t/bug_format_comment.t
new file mode 100755
index 000000000..99c17da9e
--- /dev/null
+++ b/extensions/BMO/t/bug_format_comment.t
@@ -0,0 +1,79 @@
+#!/usr/bin/perl -T
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+use strict;
+use warnings;
+use lib qw( . lib );
+
+use Test::More;
+use Bugzilla;
+use Bugzilla::Extension;
+
+my $class = Bugzilla::Extension->load('extensions/BMO/Extension.pm',
+ 'extensions/BMO/Config.pm');
+ok( $class->can('bug_format_comment'), 'the function exists');
+
+my $bmo = $class->new;
+ok($bmo, "got a new bmo extension");
+
+my $text = <<'END_OF_LINKS';
+# crash stats, a fake one
+bp-deadbeef-deaf-beef-beed-cafefeed1337
+
+# CVE/CAN security things
+CVE-2014-0160
+
+# svn
+r2424
+
+# bzr commit
+Committing to: bzr+ssh://dlawrence%40mozilla.com@bzr.mozilla.org/bmo/4.2
+modified extensions/Review/Extension.pm
+Committed revision 9257.
+
+# git with scp-style address
+To gitolite3@git.mozilla.org:bugzilla/bugzilla.git
+ 36f56bd..eab44b1 nouri -> nouri
+
+# git with uri
+To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
+ 36f56bd..eab44b1 withuri -> withuri
+END_OF_LINKS
+
+my @regexes;
+
+$bmo->bug_format_comment({ regexes => \@regexes });
+
+ok(@regexes > 0, "got some regexes to play with");
+
+foreach my $re (@regexes) {
+ my ($match, $replace) = @$re{qw(match replace)};
+ if (ref($replace) eq 'CODE') {
+ $text =~ s/$match/$replace->({matches => [ $1, $2, $3, $4,
+ $5, $6, $7, $8,
+ $9, $10]})/egx;
+ }
+ else {
+ $text =~ s/$match/$replace/egx;
+ }
+}
+
+my @links = (
+ '<a href="https://crash-stats.mozilla.com/report/index/deadbeef-deaf-beef-beed-cafefeed1337">bp-deadbeef-deaf-beef-beed-cafefeed1337</a>',
+ '<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160">CVE-2014-0160</a>',
+ '<a href="http://viewvc.svn.mozilla.org/vc?view=rev&amp;revision=2424">r2424</a>',
+ '<a href="http://git.mozilla.org/?p=bugzilla/bugzilla.git;a=commit;h=eab44b1">36f56bd..eab44b1 withuri -> withuri</a>',
+ '<a href="http://git.mozilla.org/?p=bugzilla/bugzilla.git;a=commit;h=eab44b1">36f56bd..eab44b1 nouri -> nouri</a>',
+ 'http://bzr.mozilla.org/bmo/4.2/revision/9257',
+);
+
+foreach my $link (@links) {
+ ok(index($text, $link) > -1, "check for $link");
+}
+
+
+done_testing;