summaryrefslogtreecommitdiff
path: root/app/helpers/submodule_helper.rb
diff options
context:
space:
mode:
authorDavid Turner <novalis@novalis.org>2017-04-18 01:44:16 -0400
committerDavid Turner <novalis@novalis.org>2017-04-21 10:54:31 -0400
commit040062cc8ada4e242b27e6e6fbddcf8f27d5d0c8 (patch)
tree22e357db2d63c4672f85040fd4211c817ac316ef /app/helpers/submodule_helper.rb
parentbbd83376d625b8d9cb73cbc83c3c0eb71b1abf32 (diff)
downloadgitlab-ce-040062cc8ada4e242b27e6e6fbddcf8f27d5d0c8.tar.gz
submodule_links: handle urls that don't end with .git
Signed-off-by: David Turner <novalis@novalis.org>
Diffstat (limited to 'app/helpers/submodule_helper.rb')
-rw-r--r--app/helpers/submodule_helper.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb
index fb95f2b565e..a762b320d56 100644
--- a/app/helpers/submodule_helper.rb
+++ b/app/helpers/submodule_helper.rb
@@ -5,7 +5,7 @@ module SubmoduleHelper
def submodule_links(submodule_item, ref = nil, repository = @repository)
url = repository.submodule_url_for(ref, submodule_item.path)
- return url, nil unless url =~ /([^\/:]+)\/([^\/]+\.git)\Z/
+ return url, nil unless url =~ /([^\/:]+)\/([^\/]+(?:\.git)?)\Z/
namespace = $1
project = $2
@@ -37,14 +37,16 @@ module SubmoduleHelper
end
def self_url?(url, namespace, project)
- return true if url == [Gitlab.config.gitlab.url, '/', namespace, '/',
- project, '.git'].join('')
- url == gitlab_shell.url_to_repo([namespace, '/', project].join(''))
+ url_no_dotgit = url.chomp('.git')
+ return true if url_no_dotgit == [Gitlab.config.gitlab.url, '/', namespace, '/',
+ project].join('')
+ url_with_dotgit = url_no_dotgit + '.git'
+ url_with_dotgit == gitlab_shell.url_to_repo([namespace, '/', project].join(''))
end
def relative_self_url?(url)
# (./)?(../repo.git) || (./)?(../../project/repo.git) )
- url =~ /\A((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*\.git\z/ || url =~ /\A((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*\.git\z/
+ url =~ /\A((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*(\.git)?\z/ || url =~ /\A((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*(\.git)?\z/
end
def standard_links(host, namespace, project, commit)