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:
authorYorick Peterse <yorickpeterse@gmail.com>2017-11-08 23:37:01 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2017-11-08 23:37:01 +0300
commitf37fe2edc80b83513cb9d30b6c97e85c9ccca29c (patch)
tree85707b99f07dd46fd48ba547af64e4e71ce59950 /lib/gitlab/github_import
parent48cb1c509686fc40f65ad153f36ab5d22feb63ac (diff)
Support importing GH projects without rate limits
GitHub Enterprise disables rate limiting for the API, resulting in HTTP 404 errors when requesting rate limiting details. This changes Gitlab::GithubImport::Client so it can deal with rate limiting being disabled.
Diffstat (limited to 'lib/gitlab/github_import')
-rw-r--r--lib/gitlab/github_import/client.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb
index c1c338487a7..5da9befa08e 100644
--- a/lib/gitlab/github_import/client.rb
+++ b/lib/gitlab/github_import/client.rb
@@ -129,6 +129,8 @@ module Gitlab
# whether we are running in parallel mode or not. For more information see
# `#rate_or_wait_for_rate_limit`.
def with_rate_limit
+ return yield unless rate_limiting_enabled?
+
request_count_counter.increment
raise_or_wait_for_rate_limit unless requests_remaining?
@@ -170,6 +172,10 @@ module Gitlab
octokit.rate_limit.resets_in + 5
end
+ def rate_limiting_enabled?
+ @rate_limiting_enabled ||= api_endpoint.include?('.github.com')
+ end
+
def api_endpoint
custom_api_endpoint || default_api_endpoint
end