Module: SubmoduleHelper
- Extended by:
- SubmoduleHelper
- Included in:
- SubmoduleHelper
- Defined in:
- app/helpers/submodule_helper.rb
Constant Summary collapse
- VALID_SUBMODULE_PROTOCOLS =
%w[http https git ssh].freeze
Instance Method Summary collapse
-
#submodule_links(submodule_item, ref = nil, repository = @repository, diff_file = nil) ⇒ Object
links to files listing for submodule if submodule is a project on this server.
- #submodule_links_for_url(submodule_item_id, url, repository, old_submodule_item_id = nil) ⇒ Object
Instance Method Details
#submodule_links(submodule_item, ref = nil, repository = @repository, diff_file = nil) ⇒ Object
links to files listing for submodule if submodule is a project on this server
9 10 11 |
# File 'app/helpers/submodule_helper.rb', line 9 def submodule_links(submodule_item, ref = nil, repository = @repository, diff_file = nil) repository.submodule_links.for(submodule_item, ref, diff_file) end |
#submodule_links_for_url(submodule_item_id, url, repository, old_submodule_item_id = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/submodule_helper.rb', line 13 def submodule_links_for_url(submodule_item_id, url, repository, old_submodule_item_id = nil) return [nil, nil, nil] unless url if url == '.' || url == './' url = File.join(Gitlab.config.gitlab.url, repository.project.full_path) end namespace, project = extract_namespace_project(url) if namespace.blank? || project.blank? return [sanitize_submodule_url(url), nil, nil] end if self_url?(url, namespace, project) [ url_helpers.namespace_project_path(namespace, project), url_helpers.namespace_project_tree_path(namespace, project, submodule_item_id), (url_helpers.namespace_project_compare_path(namespace, project, to: submodule_item_id, from: old_submodule_item_id) if old_submodule_item_id) ] elsif relative_self_url?(url) relative_self_links(url, submodule_item_id, old_submodule_item_id, repository.project) elsif gist_github_dot_com_url?(url) gist_github_com_tree_links(namespace, project, submodule_item_id) elsif github_dot_com_url?(url) github_com_tree_links(namespace, project, submodule_item_id, old_submodule_item_id) elsif gitlab_dot_com_url?(url) gitlab_com_tree_links(namespace, project, submodule_item_id, old_submodule_item_id) else [sanitize_submodule_url(url), nil, nil] end end |