diff options
author | Rubén Dávila <ruben@gitlab.com> | 2018-03-12 16:01:43 -0500 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2018-03-12 16:01:43 -0500 |
commit | afe2c15e6bf1005e5bd1d213d3548a1a17a11137 (patch) | |
tree | a31f89b2ab3dbec92ef11fb2cf106d190ba68668 /app/helpers | |
parent | afd2d381119c3778140c3dd63c7ef24ecdb4c62e (diff) | |
download | gitlab-ce-afe2c15e6bf1005e5bd1d213d3548a1a17a11137.tar.gz |
Fix provider server URL used when listing repos to importrd-fix-github-url-when-listing-repositories-at-importing
Also use Gitlab::Auth::OAuth::Provider.config_for to access OmniAuth config
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/import_helper.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/helpers/import_helper.rb b/app/helpers/import_helper.rb index 9149d79ecb8..4664b1728c4 100644 --- a/app/helpers/import_helper.rb +++ b/app/helpers/import_helper.rb @@ -1,4 +1,6 @@ module ImportHelper + include ::Gitlab::Utils::StrongMemoize + def has_ci_cd_only_params? false end @@ -75,17 +77,18 @@ module ImportHelper private def github_project_url(full_path) - "#{github_root_url}/#{full_path}" + URI.join(github_root_url, full_path).to_s end def github_root_url - return @github_url if defined?(@github_url) + strong_memoize(:github_url) do + provider = Gitlab::Auth::OAuth::Provider.config_for('github') - provider = Gitlab.config.omniauth.providers.find { |p| p.name == 'github' } - @github_url = provider.fetch('url', 'https://github.com') if provider + provider&.dig('url').presence || 'https://github.com' + end end def gitea_project_url(full_path) - "#{@gitea_host_url.sub(%r{/+\z}, '')}/#{full_path}" + URI.join(@gitea_host_url, full_path).to_s end end |