Aklapper has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/91372


Change subject: Sync the MoreBugUrl default extension with upstream trunk.
......................................................................

Sync the MoreBugUrl default extension with upstream trunk.

Except for small code cleanups and support for two more
bugtrackers there are no code changes.

This will make it easier to clean up our custom patches + upstream
them. See https://bugzilla.wikimedia.org/show_bug.cgi?id=56040

Change-Id: I4742206190a2c296641004838c21d127c9de934b
---
M extensions/MoreBugUrl/Extension.pm
A extensions/MoreBugUrl/lib/BitBucket.pm
M extensions/MoreBugUrl/lib/GetSatisfaction.pm
M extensions/MoreBugUrl/lib/PHP.pm
M extensions/MoreBugUrl/lib/RT.pm
A extensions/MoreBugUrl/lib/Redmine.pm
M 
extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl
7 files changed, 86 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/bugzilla/modifications 
refs/changes/72/91372/1

diff --git a/extensions/MoreBugUrl/Extension.pm 
b/extensions/MoreBugUrl/Extension.pm
index 5c71fa5..aa20a45 100644
--- a/extensions/MoreBugUrl/Extension.pm
+++ b/extensions/MoreBugUrl/Extension.pm
@@ -12,11 +12,13 @@
 use parent qw(Bugzilla::Extension);
 
 use constant MORE_SUB_CLASSES => qw(
+    Bugzilla::Extension::MoreBugUrl::BitBucket
     Bugzilla::Extension::MoreBugUrl::ReviewBoard
     Bugzilla::Extension::MoreBugUrl::Rietveld
     Bugzilla::Extension::MoreBugUrl::RT
     Bugzilla::Extension::MoreBugUrl::GetSatisfaction
     Bugzilla::Extension::MoreBugUrl::PHP
+    Bugzilla::Extension::MoreBugUrl::Redmine
 );
 
 # We need to update bug_see_also table because both
diff --git a/extensions/MoreBugUrl/lib/BitBucket.pm 
b/extensions/MoreBugUrl/lib/BitBucket.pm
new file mode 100644
index 0000000..fbb7be1
--- /dev/null
+++ b/extensions/MoreBugUrl/lib/BitBucket.pm
@@ -0,0 +1,39 @@
+# 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.
+
+package Bugzilla::Extension::MoreBugUrl::BitBucket;
+
+use 5.10.1;
+use strict;
+use parent qw(Bugzilla::BugUrl);
+
+###############################
+####        Methods        ####
+###############################
+
+sub should_handle {
+    my ($class, $uri) = @_;
+
+    # BitBucket issues have the form of
+    # bitbucket.org/user/project/issue/1234
+    return (lc($uri->authority) eq "bitbucket.org"
+            && $uri->path =~ m|[^/]+/[^/]+/issue/\d+|i) ? 1 : 0;
+}
+
+sub _check_value {
+    my $class = shift;
+
+    my $uri = $class->SUPER::_check_value(@_);
+
+    my ($path) = $uri->path =~ m|([^/]+/[^/]+/issue/\d+)|i;
+    $uri = new URI("https://bitbucket.org/$path";);
+
+    return $uri;
+}
+
+1;
+
diff --git a/extensions/MoreBugUrl/lib/GetSatisfaction.pm 
b/extensions/MoreBugUrl/lib/GetSatisfaction.pm
index 4c077b1..75d5ece 100644
--- a/extensions/MoreBugUrl/lib/GetSatisfaction.pm
+++ b/extensions/MoreBugUrl/lib/GetSatisfaction.pm
@@ -20,7 +20,7 @@
 
     # GetSatisfaction URLs only have one form:
     #   http(s)://getsatisfaction.com/PROJECT_NAME/topics/TOPIC_NAME
-    return ($uri->authority =~ /^getsatisfaction.com$/i
+    return (lc($uri->authority) eq 'getsatisfaction.com'
             and $uri->path =~ m|^/[^/]+/topics/[^/]+$|) ? 1 : 0;
 }
 
diff --git a/extensions/MoreBugUrl/lib/PHP.pm b/extensions/MoreBugUrl/lib/PHP.pm
index 1521cae..ea090e8 100644
--- a/extensions/MoreBugUrl/lib/PHP.pm
+++ b/extensions/MoreBugUrl/lib/PHP.pm
@@ -20,8 +20,8 @@
 
     # PHP Bug URLs have only one form:
     #   https://bugs.php.net/bug.php?id=1234
-    return ($uri->authority =~ /^bugs.php.net$/i
-            and $uri->path =~ m|/bug.php$|
+    return (lc($uri->authority) eq 'bugs.php.net'
+            and $uri->path =~ m|/bug\.php$|
             and $uri->query_param('id') =~ /^\d+$/) ? 1 : 0;
 }
 
diff --git a/extensions/MoreBugUrl/lib/RT.pm b/extensions/MoreBugUrl/lib/RT.pm
index 7244568..a1ca6fd 100644
--- a/extensions/MoreBugUrl/lib/RT.pm
+++ b/extensions/MoreBugUrl/lib/RT.pm
@@ -21,7 +21,7 @@
     # RT URLs can look like various things:
     #   http://example.com/rt/Ticket/Display.html?id=1234
     #   https://example.com/Public/Bug/Display.html?id=1234
-    return ($uri->path =~ m|/Display.html$|
+    return ($uri->path =~ m|/Display\.html$|
             and $uri->query_param('id') =~ /^\d+$/) ? 1 : 0;
 }
 
diff --git a/extensions/MoreBugUrl/lib/Redmine.pm 
b/extensions/MoreBugUrl/lib/Redmine.pm
new file mode 100644
index 0000000..a1c1382
--- /dev/null
+++ b/extensions/MoreBugUrl/lib/Redmine.pm
@@ -0,0 +1,39 @@
+# 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.
+
+package Bugzilla::Extension::MoreBugUrl::Redmine;
+
+use 5.10.1;
+use strict;
+use parent qw(Bugzilla::BugUrl);
+
+###############################
+####        Methods        ####
+###############################
+
+sub should_handle {
+    my ($class, $uri) = @_;
+    return ($uri->path =~ m|/issues/\d+$|) ? 1 : 0;
+}
+
+sub _check_value {
+    my $class = shift;
+
+    my $uri = $class->SUPER::_check_value(@_);
+
+    # Redmine URLs have only one form:
+    #   http://demo.redmine.com/issues/111
+
+    # Make sure there are no query parameters.
+    $uri->query(undef);
+    # And remove any # part if there is one.
+    $uri->fragment(undef);
+
+    return $uri;
+}
+
+1;
diff --git 
a/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl
 
b/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl
index 7683e42..65592a9 100644
--- 
a/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl
+++ 
b/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl
@@ -6,8 +6,10 @@
   # defined by the Mozilla Public License, v. 2.0.
   #%]
 
+<li>An issue on bitbucket.org.</li>
 <li>A Review Board review request.</li>
 <li>An issue in a Rietveld installation.</li>
 <li>A ticket in an RT installation.</li>
 <li>A topic on getsatisfaction.com.</li>
 <li>A b[% %]ug on b[% %]ugs.php.net.</li>
+<li>An issue in a Redmine installation.</li>

-- 
To view, visit https://gerrit.wikimedia.org/r/91372
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4742206190a2c296641004838c21d127c9de934b
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/bugzilla/modifications
Gerrit-Branch: master
Gerrit-Owner: Aklapper <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to