Skip to content
Snippets Groups Projects
Commit fe8c9021 authored by Timm Drevensek's avatar Timm Drevensek
Browse files

Add support for relative submodules

parent 1c7aecc8
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,6 +3,7 @@ v 6.7.0
- Add edit file button to MergeRequest diff
- Public groups (Jason Hollingsworth)
- Cleaner headers in Notification Emails (Pierre de La Morinerie)
- Add support for relative submodules
 
v 6.6.2
- Fix 500 error on branch/tag create or remove via UI
Loading
Loading
Loading
Loading
@@ -12,6 +12,8 @@ module SubmoduleHelper
 
if self_url?(url, project)
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)
standard_links('github.com', project, submodule_item.id)
elsif gitlab_dot_com_url?(url)
Loading
Loading
@@ -36,8 +38,23 @@ module SubmoduleHelper
url == gitlab_shell.url_to_repo(project)
end
 
def relative_self_url?(url)
# (./)? ( (../repo.git) | (../../project/repo.git) )
url =~ /(^((\.\/)?(((\.\.)\/)|((\.\.)\/(\.\.)\/.*\/)))[^\.\/]*\.git)\Z/
end
def standard_links(host, project, commit)
base = [ 'https://', host, '/', project ].join('')
return base, [ base, '/tree/', commit ].join('')
end
def relative_self_links(url, commit)
if url.scan(/(\.\.)/).size == 2
base = [ Gitlab.config.gitlab.url, '/', url[/.*\/(.*)\/.*\.git/, 1] ].join('')
else
base = [ Gitlab.config.gitlab.url, '/', @project.group.path ].join('')
end
base = [ base, '/', url[/.*\/(.*)\.git/, 1] ].join('')
return base, [ base, '/tree/', commit ].join('')
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment