From 17223fe4f88ee5258bef855d3066593e97ca6952 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Fri, 24 Jan 2014 14:55:57 -0800 Subject: [PATCH 1/4] Link RT subject tag style ticket references, i.e. "[rt.cpan.org #NNN]" and "rt.cpan.org #NNN" --- lib/MetaCPAN/Web/Model/API/Changes.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/MetaCPAN/Web/Model/API/Changes.pm b/lib/MetaCPAN/Web/Model/API/Changes.pm index 4117cc8b46..d442373dad 100644 --- a/lib/MetaCPAN/Web/Model/API/Changes.pm +++ b/lib/MetaCPAN/Web/Model/API/Changes.pm @@ -96,6 +96,9 @@ sub _rt_cpan { # Some other cases $line =~ s{\b(bug\s+\#)(\d+)\b}{$u$2">$1$2}gxi; + # Subject tag style + $line =~ s{(\[?rt\.cpan\.org\s+\#(\d+)\]?)}{$u$2">$1}gxi; + return $line; } From 46b80e1957392e1811c947239192b4036da70a40 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Fri, 24 Jan 2014 14:57:00 -0800 Subject: [PATCH 2/4] Link PR#NN, PR:NN, and PR-NN to Github in changelogs PR is often used when denoting pull requests. The numbers share the same sequence as GH issues. --- lib/MetaCPAN/Web/Model/API/Changes.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/MetaCPAN/Web/Model/API/Changes.pm b/lib/MetaCPAN/Web/Model/API/Changes.pm index d442373dad..ad7246dff2 100644 --- a/lib/MetaCPAN/Web/Model/API/Changes.pm +++ b/lib/MetaCPAN/Web/Model/API/Changes.pm @@ -105,8 +105,8 @@ sub _rt_cpan { sub _gh { my ($self, $line, $bt) = @_; $bt =~ s|/$||; - $line =~ s{(GH[-:]?)(\d+)\b}{$1$2}gxi; - $line =~ s{((?:GH|)[#])(\d+)\b}{$1$2}gxi; + $line =~ s{((?:GH|PR)[-:]?)(\d+)\b}{$1$2}gxi; + $line =~ s{((?:GH|PR|)[#])(\d+)\b}{$1$2}gxi; return $line; } 1; From 6472bcb270f97f6516f25f3f80d93a6a4f03dbba Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Mon, 27 Jan 2014 23:09:34 -0800 Subject: [PATCH 3/4] These aren't patterns, they're substrings. Escape any metachars. --- t/model/changes.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/model/changes.t b/t/model/changes.t index ec85a55f8d..4497d11c1e 100644 --- a/t/model/changes.t +++ b/t/model/changes.t @@ -27,7 +27,7 @@ subtest "RT ticket linking" => sub { ); 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"); } }; @@ -42,7 +42,7 @@ subtest "GH issue linking" => sub { 'Add HTTP logger (gh-16; thanks djzort!)' => 'issues/16">gh-16', ); 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' From 48cc94fa07dc91e5d99dd293d9fa9a578a6cb9a5 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Mon, 27 Jan 2014 23:09:56 -0800 Subject: [PATCH 4/4] Test new RT and Github link formats in changelogs --- t/model/changes.t | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/t/model/changes.t b/t/model/changes.t index 4497d11c1e..0130f0e409 100644 --- a/t/model/changes.t +++ b/t/model/changes.t @@ -24,6 +24,8 @@ 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]', + 'Blah blah rt.cpan.org #231 fixed' => 'id=231">rt.cpan.org #231', ); while (my ($in, $out) = each %rt_tests) { @@ -40,6 +42,9 @@ 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', + 'Merged PR:1013 -- thanks' => 'issues/1013">PR:1013', + 'Merged PR-1013 -- thanks' => 'issues/1013">PR-1013', ); while (my ($in, $out) = each %gh_tests) { like(Changes->_gh($in, $u), qr/\Q$out\E/, "$in found");