diff options
author | Timm Drevensek <abubadabu@gmail.com> | 2014-02-26 01:42:45 +0400 |
---|---|---|
committer | Timm Drevensek <abubadabu@gmail.com> | 2014-02-26 01:42:45 +0400 |
commit | fe8c9021266c579127cf52f6456eb0090e400e63 (patch) | |
tree | 8d8621cd816e7849e544dac20ca1a5c29443839c /app/helpers | |
parent | 1c7aecc8f5be4eee30b44a188cbae8341a67f740 (diff) |
Add support for relative submodules
Diffstat (limited to 'app/helpers')
-rwxr-xr-x[-rw-r--r--] | app/helpers/submodule_helper.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index 56f6e4d9cc1..ca7b87b69ad 100644..100755 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -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) @@ -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 |