Skip to content

Commit 4543712

Browse files
committed
Bug 999668 - We don't linkify the alternative ssh remote syntax
r=glob
1 parent b2eb600 commit 4543712

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

extensions/BMO/Extension.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ sub bug_format_comment {
482482

483483
# link git.mozilla.org commit messages
484484
push (@$regexes, {
485-
match => qr#^(To\sssh://[^\@]+\@git\.mozilla\.org\/(.+?.git)\n
485+
match => qr#^(To\s(?:ssh://)?[^\@]+\@git\.mozilla\.org[:/](.+?\.git)\n
486486
\s+)([0-9a-z]+\.\.([0-9a-z]+)\s+\S+\s->\s\S+)#mx,
487487
replace => sub {
488488
my $args = shift;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/perl -T
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
5+
#
6+
# This Source Code Form is "Incompatible With Secondary Licenses", as
7+
# defined by the Mozilla Public License, v. 2.0.
8+
use strict;
9+
use warnings;
10+
use lib qw( . lib );
11+
12+
use Test::More;
13+
use Bugzilla;
14+
use Bugzilla::Extension;
15+
16+
my $class = Bugzilla::Extension->load('extensions/BMO/Extension.pm',
17+
'extensions/BMO/Config.pm');
18+
ok( $class->can('bug_format_comment'), 'the function exists');
19+
20+
my $bmo = $class->new;
21+
ok($bmo, "got a new bmo extension");
22+
23+
my $text = <<'END_OF_LINKS';
24+
# crash stats, a fake one
25+
bp-deadbeef-deaf-beef-beed-cafefeed1337
26+
27+
# CVE/CAN security things
28+
CVE-2014-0160
29+
30+
# svn
31+
r2424
32+
33+
# bzr commit
34+
Committing to: bzr+ssh://dlawrence%40mozilla.com@bzr.mozilla.org/bmo/4.2
35+
modified extensions/Review/Extension.pm
36+
Committed revision 9257.
37+
38+
# git with scp-style address
39+
To gitolite3@git.mozilla.org:bugzilla/bugzilla.git
40+
36f56bd..eab44b1 nouri -> nouri
41+
42+
# git with uri
43+
To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
44+
36f56bd..eab44b1 withuri -> withuri
45+
END_OF_LINKS
46+
47+
my @regexes;
48+
49+
$bmo->bug_format_comment({ regexes => \@regexes });
50+
51+
ok(@regexes > 0, "got some regexes to play with");
52+
53+
foreach my $re (@regexes) {
54+
my ($match, $replace) = @$re{qw(match replace)};
55+
if (ref($replace) eq 'CODE') {
56+
$text =~ s/$match/$replace->({matches => [ $1, $2, $3, $4,
57+
$5, $6, $7, $8,
58+
$9, $10]})/egx;
59+
}
60+
else {
61+
$text =~ s/$match/$replace/egx;
62+
}
63+
}
64+
65+
my @links = (
66+
'<a href="https://crash-stats.mozilla.com/report/index/deadbeef-deaf-beef-beed-cafefeed1337">bp-deadbeef-deaf-beef-beed-cafefeed1337</a>',
67+
'<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160">CVE-2014-0160</a>',
68+
'<a href="http://viewvc.svn.mozilla.org/vc?view=rev&amp;revision=2424">r2424</a>',
69+
'<a href="http://git.mozilla.org/?p=bugzilla/bugzilla.git;a=commit;h=eab44b1">36f56bd..eab44b1 withuri -> withuri</a>',
70+
'<a href="http://git.mozilla.org/?p=bugzilla/bugzilla.git;a=commit;h=eab44b1">36f56bd..eab44b1 nouri -> nouri</a>',
71+
'http://bzr.mozilla.org/bmo/4.2/revision/9257',
72+
);
73+
74+
foreach my $link (@links) {
75+
ok(index($text, $link) > -1, "check for $link");
76+
}
77+
78+
79+
done_testing;

0 commit comments

Comments
 (0)