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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /lib/gitlab/github_import.rb
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'lib/gitlab/github_import.rb')
-rw-r--r--lib/gitlab/github_import.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/gitlab/github_import.rb b/lib/gitlab/github_import.rb
index 9a7c406d981..c3cc15e10f7 100644
--- a/lib/gitlab/github_import.rb
+++ b/lib/gitlab/github_import.rb
@@ -6,10 +6,13 @@ module Gitlab
[:heads, :tags, '+refs/pull/*/head:refs/merge-requests/*/head']
end
- def self.new_client_for(project, token: nil, parallel: true)
+ def self.new_client_for(project, token: nil, host: nil, parallel: true)
token_to_use = token || project.import_data&.credentials&.fetch(:user)
-
- Client.new(token_to_use, parallel: parallel)
+ Client.new(
+ token_to_use,
+ host: host.presence || self.formatted_import_url(project),
+ parallel: parallel
+ )
end
# Returns the ID of the ghost user.
@@ -18,5 +21,17 @@ module Gitlab
Gitlab::Cache::Import::Caching.read_integer(key) || Gitlab::Cache::Import::Caching.write(key, User.select(:id).ghost.id)
end
+
+ # Get formatted GitHub import URL. If github.com is in the import URL, this will return nil and octokit will use the default github.com API URL
+ def self.formatted_import_url(project)
+ url = URI.parse(project.import_url)
+
+ unless url.host == 'github.com'
+ url.user = nil
+ url.password = nil
+ url.path = "/api/v3"
+ url.to_s
+ end
+ end
end
end