summaryrefslogtreecommitdiff
path: root/app/helpers/import_helper.rb
blob: 109bc1a02d19bdbc8c8140aca3dc3e54d9af4bde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module ImportHelper
  def github_project_link(path_with_namespace)
    link_to path_with_namespace, github_project_url(path_with_namespace), target: '_blank'
  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
end