Commit 2ceef7691795958e657f24d78089eecb0eb4a90d

Authored by Dmitriy Zaporozhets
2 parents 7ae488ed 2f945ac5

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

Showing 1 changed file with 16 additions and 0 deletions   Show diff stats
app/helpers/submodule_helper.rb 100644 → 100755
... ... @@ -12,6 +12,8 @@ module SubmoduleHelper
12 12  
13 13 if self_url?(url, project)
14 14 return project_path(project), project_tree_path(project, submodule_item.id)
  15 + elsif relative_self_url?(url)
  16 + relative_self_links(url, submodule_item.id)
15 17 elsif github_dot_com_url?(url)
16 18 standard_links('github.com', project, submodule_item.id)
17 19 elsif gitlab_dot_com_url?(url)
... ... @@ -36,8 +38,22 @@ module SubmoduleHelper
36 38 url == gitlab_shell.url_to_repo(project)
37 39 end
38 40  
  41 + def relative_self_url?(url)
  42 + # (./)?(../repo.git) || (./)?(../../project/repo.git) )
  43 + url =~ /^((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*\.git\Z/ || url =~ /^((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*\.git\Z/
  44 + end
  45 +
39 46 def standard_links(host, project, commit)
40 47 base = [ 'https://', host, '/', project ].join('')
41 48 return base, [ base, '/tree/', commit ].join('')
42 49 end
  50 +
  51 + def relative_self_links(url, commit)
  52 + if url.scan(/(\.\.\/)/).size == 2
  53 + base = url[/([^\/]*\/[^\/]*)\.git/, 1]
  54 + else
  55 + base = [ @project.group.path, '/', url[/([^\/]*)\.git/, 1] ].join('')
  56 + end
  57 + return project_path(base), project_tree_path(base, commit)
  58 + end
43 59 end
... ...