]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1309112 - Detect and linkify GitHub issue in comment
authorSebastin Santy <sebastinssanty@gmail.com>
Wed, 15 Mar 2017 20:19:05 +0000 (16:19 -0400)
committerDylan William Hardison <dylan@hardison.net>
Wed, 15 Mar 2017 20:20:17 +0000 (16:20 -0400)
extensions/BMO/Extension.pm

index 8412a2518e461cea6eb3c198fce157084c8125e9..1640bd076ea8351f96d3eedb1e168f73690c5ada 100644 (file)
@@ -720,6 +720,18 @@ sub bug_format_comment {
         }
     });
 
+    # link github pull requests and issues
+    push (@$regexes, {
+        match => qr/(\s)([A-Za-z0-9_\.-]+)\/([A-Za-z0-9_\.-]+)\#([0-9]+)\b/,
+        replace => sub {
+            my $args = shift;
+            my $owner = html_quote($args->{matches}->[1]);
+            my $repo = html_quote($args->{matches}->[2]);
+            my $number = html_quote($args->{matches}->[3]);
+            return qq# <a href="https://github.com/$owner/$repo/issues/$number">$owner/$repo\#$number</a>#;
+        }
+    });
+
     # Update certain links to git.mozilla.org to go to github.com instead
     # https://git.mozilla.org/?p=webtools/bmo/bugzilla.git;a=blob;f=Bugzilla/WebService/Bug.pm;h=d7a1d8f9bb5fdee524f2bb342a4573a63d890f2e;hb=HEAD#l657
     push(@$regexes, {