debian-mirror-gitlab/app/helpers/import_helper.rb

30 lines
906 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
module ImportHelper
2016-09-29 09:46:39 +05:30
def import_project_target(owner, name)
namespace = current_user.can_create_group? ? owner : current_user.namespace_path
"#{namespace}/#{name}"
end
2017-08-17 22:00:37 +05:30
def provider_project_link(provider, path_with_namespace)
2018-03-17 18:26:18 +05:30
url = __send__("#{provider}_project_url", path_with_namespace) # rubocop:disable GitlabSecurity/PublicSend
2017-08-17 22:00:37 +05:30
link_to path_with_namespace, url, target: '_blank', rel: 'noopener noreferrer'
2016-06-02 11:05:42 +05:30
end
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
2017-08-17 22:00:37 +05:30
def gitea_project_url(path_with_namespace)
"#{@gitea_host_url.sub(%r{/+\z}, '')}/#{path_with_namespace}"
end
2016-06-02 11:05:42 +05:30
end