Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/MetaCPAN/Web/Model/API/Changes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,17 @@ sub _rt_cpan {
# Some other cases
$line =~ s{\b(bug\s+\#)(\d+)\b}{$u$2">$1$2</a>}gxi;

# Subject tag style
$line =~ s{(\[?rt\.cpan\.org\s+\#(\d+)\]?)}{$u$2">$1</a>}gxi;

return $line;
}

sub _gh {
my ($self, $line, $bt) = @_;
$bt =~ s|/$||;
$line =~ s{(GH[-:]?)(\d+)\b}{<a href=$bt/$2">$1$2</a>}gxi;
$line =~ s{((?:GH|)[#])(\d+)\b}{<a href="$bt/$2">$1$2</a>}gxi;
$line =~ s{((?:GH|PR)[-:]?)(\d+)\b}{<a href=$bt/$2">$1$2</a>}gxi;
$line =~ s{((?:GH|PR|)[#])(\d+)\b}{<a href="$bt/$2">$1$2</a>}gxi;
return $line;
}
1;
9 changes: 7 additions & 2 deletions t/model/changes.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ subtest "RT ticket linking" => sub {
'id=87550">rt87550',
'Fix bug #87801 where excluded tags were ANDed instead of ORed. Stefan Corneliu Petrea.' =>
'id=87801">bug #87801',
'Blah blah [rt.cpan.org #231] fixed' => 'id=231">[rt.cpan.org #231]</a>',
'Blah blah rt.cpan.org #231 fixed' => 'id=231">rt.cpan.org #231</a>',
);

while (my ($in, $out) = each %rt_tests) {
like(Changes->_rt_cpan($in), qr/$out/, "$in found");
like(Changes->_rt_cpan($in), qr/\Q$out\E/, "$in found");
}
};

Expand All @@ -40,9 +42,12 @@ subtest "GH issue linking" => sub {
'Fixed GH:1013' => 'issues/1013">GH:1013',
'Fixed GH #1013' => 'issues/1013">#1013',
'Add HTTP logger (gh-16; thanks djzort!)' => 'issues/16">gh-16',
'Merged PR#1013 -- thanks' => 'issues/1013">PR#1013</a>',
'Merged PR:1013 -- thanks' => 'issues/1013">PR:1013</a>',
'Merged PR-1013 -- thanks' => 'issues/1013">PR-1013</a>',
);
while (my ($in, $out) = each %gh_tests) {
like(Changes->_gh($in, $u), qr/$out/, "$in found");
like(Changes->_gh($in, $u), qr/\Q$out\E/, "$in found");
}
my @no_links_tests = (
'I wash my hands of this library forever -- rjbs, 2013-10-15'
Expand Down