Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2018-03-13 00:01:43 +0300
committerRubén Dávila <ruben@gitlab.com>2018-03-13 00:01:43 +0300
commitafe2c15e6bf1005e5bd1d213d3548a1a17a11137 (patch)
treea31f89b2ab3dbec92ef11fb2cf106d190ba68668 /app/helpers/import_helper.rb
parentafd2d381119c3778140c3dd63c7ef24ecdb4c62e (diff)
Fix provider server URL used when listing repos to import
Also use Gitlab::Auth::OAuth::Provider.config_for to access OmniAuth config
Diffstat (limited to 'app/helpers/import_helper.rb')
-rw-r--r--app/helpers/import_helper.rb13
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