Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-06-05 09:26:20 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-06-05 09:26:20 +0300
commit2eec0b73e8201761e9c350621651d2949dea52af (patch)
tree1001f9fbd258d4f369a150983891bb2179cc07b4 /app/helpers/submodule_helper.rb
parent64a22c562814703419a818941d85e2309312ba0c (diff)
Fix submodule link to then project under subgroup
Before this change only last namespace in full path was extracted. It's fine unless you have a link to submodule under subgroups. In that case self_url? method returns false and link is processed as external. I could not find a proper regex to cover all cases and correctly extract full path to repository and instead used current instance host name to get correct path to namespace and project. Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/helpers/submodule_helper.rb')
-rw-r--r--app/helpers/submodule_helper.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb
index c0763a8a9c4..8e0a1e2ecdf 100644
--- a/app/helpers/submodule_helper.rb
+++ b/app/helpers/submodule_helper.rb
@@ -13,6 +13,17 @@ module SubmoduleHelper
if url =~ /([^\/:]+)\/([^\/]+(?:\.git)?)\Z/
namespace, project = $1, $2
+ gitlab_hosts = [Gitlab.config.gitlab.url,
+ Gitlab.config.gitlab_shell.ssh_path_prefix]
+
+ gitlab_hosts.each do |host|
+ if url.start_with?(host)
+ namespace, _, project = url.sub(host, '').rpartition('/')
+ break
+ end
+ end
+
+ namespace.sub!(/\A\//, '')
project.rstrip!
project.sub!(/\.git\z/, '')