Commit 2ceef769 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce

parents 7ae488ed 2f945ac5
...@@ -12,6 +12,8 @@ module SubmoduleHelper ...@@ -12,6 +12,8 @@ module SubmoduleHelper
if self_url?(url, project) if self_url?(url, project)
return project_path(project), project_tree_path(project, submodule_item.id) return project_path(project), project_tree_path(project, submodule_item.id)
elsif relative_self_url?(url)
relative_self_links(url, submodule_item.id)
elsif github_dot_com_url?(url) elsif github_dot_com_url?(url)
standard_links('github.com', project, submodule_item.id) standard_links('github.com', project, submodule_item.id)
elsif gitlab_dot_com_url?(url) elsif gitlab_dot_com_url?(url)
...@@ -36,8 +38,22 @@ module SubmoduleHelper ...@@ -36,8 +38,22 @@ module SubmoduleHelper
url == gitlab_shell.url_to_repo(project) url == gitlab_shell.url_to_repo(project)
end end
def relative_self_url?(url)
# (./)?(../repo.git) || (./)?(../../project/repo.git) )
url =~ /^((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*\.git\Z/ || url =~ /^((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*\.git\Z/
end
def standard_links(host, project, commit) def standard_links(host, project, commit)
base = [ 'https://', host, '/', project ].join('') base = [ 'https://', host, '/', project ].join('')
return base, [ base, '/tree/', commit ].join('') return base, [ base, '/tree/', commit ].join('')
end end
def relative_self_links(url, commit)
if url.scan(/(\.\.\/)/).size == 2
base = url[/([^\/]*\/[^\/]*)\.git/, 1]
else
base = [ @project.group.path, '/', url[/([^\/]*)\.git/, 1] ].join('')
end
return project_path(base), project_tree_path(base, commit)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment