summaryrefslogtreecommitdiff
path: root/app/controllers/import/github_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/import/github_controller.rb')
-rw-r--r--app/controllers/import/github_controller.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb
index c418b11ab13..34af1ecd6a5 100644
--- a/app/controllers/import/github_controller.rb
+++ b/app/controllers/import/github_controller.rb
@@ -9,6 +9,7 @@ class Import::GithubController < Import::BaseController
before_action :expire_etag_cache, only: [:status, :create]
rescue_from Octokit::Unauthorized, with: :provider_unauthorized
+ rescue_from Octokit::TooManyRequests, with: :provider_rate_limit
def new
if !ci_cd_only? && github_import_configured? && logged_in_with_provider?
@@ -142,6 +143,13 @@ class Import::GithubController < Import::BaseController
alert: "Access denied to your #{Gitlab::ImportSources.title(provider.to_s)} account."
end
+ def provider_rate_limit(exception)
+ reset_time = Time.at(exception.response_headers['x-ratelimit-reset'].to_i)
+ session[access_token_key] = nil
+ redirect_to new_import_url,
+ alert: _("GitHub API rate limit exceeded. Try again after %{reset_time}") % { reset_time: reset_time }
+ end
+
def access_token_key
:"#{provider}_access_token"
end
@@ -180,7 +188,7 @@ class Import::GithubController < Import::BaseController
end
def client_options
- {}
+ { wait_for_rate_limit_reset: false }
end
def extra_import_params