diff options
author | Vinnie Okada <vokada@mrvinn.com> | 2015-01-24 11:02:58 -0700 |
---|---|---|
committer | Vinnie Okada <vokada@mrvinn.com> | 2015-02-14 11:09:23 -0700 |
commit | 76aad9b76ed756ca9ba2cbcdb399c815e542b3ae (patch) | |
tree | 7226e0ce64796abbf4848582baed8d173ddecd14 /app/helpers/submodule_helper.rb | |
parent | 5725b6daad2f403f13112cfcafa5b45ac126c0ca (diff) | |
download | gitlab-ce-76aad9b76ed756ca9ba2cbcdb399c815e542b3ae.tar.gz |
Upgrade to Rails 4.1.9
Make the following changes to deal with new behavior in Rails 4.1.2:
* Use nested resources to avoid slashes in arguments to path helpers.
Diffstat (limited to 'app/helpers/submodule_helper.rb')
-rw-r--r-- | app/helpers/submodule_helper.rb | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index 841e7fd17f6..525266fb3b5 100644 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -5,19 +5,22 @@ module SubmoduleHelper def submodule_links(submodule_item, ref = nil) url = @repository.submodule_url_for(ref, submodule_item.path) - return url, nil unless url =~ /([^\/:]+\/[^\/]+\.git)\Z/ + return url, nil unless url =~ /([^\/:]+)\/([^\/]+\.git)\Z/ - project = $1 + namespace = $1 + project = $2 project.chomp!('.git') - if self_url?(url, project) - return project_path(project), project_tree_path(project, submodule_item.id) + if self_url?(url, namespace, project) + return namespace_project_path(namespace, project), + namespace_project_tree_path(namespace, 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) + standard_links('github.com', namespace, project, submodule_item.id) elsif gitlab_dot_com_url?(url) - standard_links('gitlab.com', project, submodule_item.id) + standard_links('gitlab.com', namespace, project, submodule_item.id) else return url, nil end @@ -33,9 +36,10 @@ module SubmoduleHelper url =~ /gitlab\.com[\/:][^\/]+\/[^\/]+\Z/ end - def self_url?(url, project) - return true if url == [ Gitlab.config.gitlab.url, '/', project, '.git' ].join('') - url == gitlab_shell.url_to_repo(project) + 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('')) end def relative_self_url?(url) @@ -43,8 +47,8 @@ module SubmoduleHelper url =~ /^((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*\.git\Z/ || url =~ /^((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*\.git\Z/ end - def standard_links(host, project, commit) - base = [ 'https://', host, '/', project ].join('') + def standard_links(host, namespace, project, commit) + base = [ 'https://', host, '/', namespace, '/', project ].join('') return base, [ base, '/tree/', commit ].join('') end @@ -54,6 +58,7 @@ module SubmoduleHelper else base = [ @project.group.path, '/', url[/([^\/]*)\.git/, 1] ].join('') end - return project_path(base), project_tree_path(base, commit) + return namespace_project_path(base.namespace, base), + namespace_project_tree_path(base.namespace, base, commit) end end |