2016-04-18 23:01:33 +00:00
|
|
|
module ImportHelper
|
2016-08-29 21:17:11 +00:00
|
|
|
def import_project_target(owner, name)
|
|
|
|
namespace = current_user.can_create_group? ? owner : current_user.namespace_path
|
|
|
|
"#{namespace}/#{name}"
|
|
|
|
end
|
|
|
|
|
2016-12-16 09:47:26 +00:00
|
|
|
def provider_project_link(provider, path_with_namespace)
|
2017-08-10 16:39:26 +00:00
|
|
|
url = __send__("#{provider}_project_url", path_with_namespace) # rubocop:disable GitlabSecurity/PublicSend
|
2016-04-18 23:01:33 +00:00
|
|
|
|
2017-03-15 21:21:48 +00:00
|
|
|
link_to path_with_namespace, url, target: '_blank', rel: 'noopener noreferrer'
|
2016-10-17 15:58:57 +00:00
|
|
|
end
|
|
|
|
|
2016-04-18 23:01:33 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def github_project_url(path_with_namespace)
|
|
|
|
"#{github_root_url}/#{path_with_namespace}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def github_root_url
|
|
|
|
return @github_url if defined?(@github_url)
|
|
|
|
|
|
|
|
provider = Gitlab.config.omniauth.providers.find { |p| p.name == 'github' }
|
|
|
|
@github_url = provider.fetch('url', 'https://github.com') if provider
|
|
|
|
end
|
2016-10-17 15:58:57 +00:00
|
|
|
|
2016-12-15 16:36:53 +00:00
|
|
|
def gitea_project_url(path_with_namespace)
|
|
|
|
"#{@gitea_host_url.sub(%r{/+\z}, '')}/#{path_with_namespace}"
|
2016-10-17 15:58:57 +00:00
|
|
|
end
|
2016-04-18 23:01:33 +00:00
|
|
|
end
|