diff options
author | dklawren <dklawren@users.noreply.github.com> | 2019-08-29 09:38:13 -0400 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2021-08-15 10:18:17 +0200 |
commit | fb1b1c796b1fb13ab52bb4ff45952598c7e2ca03 (patch) | |
tree | 1637e0f17707315f02d5f9bb369f0f043c96de71 | |
parent | Fix sending bug mail after perl upgrade (diff) | |
download | bugzilla-fb1b1c796b1fb13ab52bb4ff45952598c7e2ca03.tar.gz bugzilla-fb1b1c796b1fb13ab52bb4ff45952598c7e2ca03.tar.bz2 bugzilla-fb1b1c796b1fb13ab52bb4ff45952598c7e2ca03.zip |
Bug 1575003 - Can't link to gitlab issues in the "see also" field
Patch from https://github.com/mozilla-bteam/bmo/commit/3751928389c0062877ac23b5040226f849a88cfd.
Thanks to asturm for digging it up.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | Bugzilla/BugUrl.pm | 1 | ||||
-rw-r--r-- | Bugzilla/BugUrl/GitLab.pm | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm index 5d62d1b17..42e993bf4 100644 --- a/Bugzilla/BugUrl.pm +++ b/Bugzilla/BugUrl.pm @@ -65,6 +65,7 @@ use constant SUB_CLASSES => qw( Bugzilla::BugUrl::MantisBT Bugzilla::BugUrl::SourceForge Bugzilla::BugUrl::GitHub + Bugzilla::BugUrl::GitLab ); ############################### diff --git a/Bugzilla/BugUrl/GitLab.pm b/Bugzilla/BugUrl/GitLab.pm new file mode 100644 index 000000000..8e546c1dc --- /dev/null +++ b/Bugzilla/BugUrl/GitLab.pm @@ -0,0 +1,45 @@ +# 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::BugUrl::GitLab; + +use 5.10.1; +use strict; +use warnings; + +use base qw(Bugzilla::BugUrl); + +############################### +#### Methods #### +############################### + +sub should_handle { + my ($class, $uri) = @_; + +# GitLab issue URLs can have the form: +# https://gitlab.com/projectA/subprojectB/subprojectC/../issues/53 + return ($uri->path =~ m!^/.*/issues/\d+$!) ? 1 : 0; +} + +sub _check_value { + my ($class, $uri) = @_; + + $uri = $class->SUPER::_check_value($uri); + + # Require the HTTPS scheme. + $uri->scheme('https'); + + # Make sure there are no query parameters. + $uri->query(undef); + + # And remove any # part if there is one. + $uri->fragment(undef); + + return $uri; +} + +1; |