BigW Consortium Gitlab

import_helper.rb 862 Bytes
Newer Older
1
module ImportHelper
2 3 4 5 6
  def import_project_target(owner, name)
    namespace = current_user.can_create_group? ? owner : current_user.namespace_path
    "#{namespace}/#{name}"
  end

7 8
  def provider_project_link(provider, path_with_namespace)
    url = __send__("#{provider}_project_url", path_with_namespace)
9

10
    link_to path_with_namespace, url, target: '_blank', rel: 'noopener noreferrer'
Kim "BKC" Carlbäcker committed
11 12
  end

13 14 15 16 17 18 19 20 21 22 23 24
  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
Kim "BKC" Carlbäcker committed
25

26 27
  def gitea_project_url(path_with_namespace)
    "#{@gitea_host_url.sub(%r{/+\z}, '')}/#{path_with_namespace}"
Kim "BKC" Carlbäcker committed
28
  end
29
end