summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-11 18:53:39 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-12 12:14:17 -0300
commitbe9262dd951e056e832ec51f8b74a8cb7ce866b4 (patch)
tree0108c8ee4545b7297e52f9d131e90240a9239221 /lib
parent3ddcd0d699153363359faf28ab9f53cfd46a1cf9 (diff)
downloadgitlab-ce-be9262dd951e056e832ec51f8b74a8cb7ce866b4.tar.gz
Checks if rate limit is enabled instead of stubbing response
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/github_import/client.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb
index f57f5b74706..f2e220fcb3e 100644
--- a/lib/gitlab/github_import/client.rb
+++ b/lib/gitlab/github_import/client.rb
@@ -82,11 +82,15 @@ module Gitlab
# disabled. In this case we just want to return gracefully
# instead of spitting out an error.
rescue Octokit::NotFound
- OpenStruct.new(remaining: GITHUB_SAFE_REMAINING_REQUESTS + 1)
+ nil
+ end
+
+ def has_rate_limit?
+ rate_limit.present?
end
def rate_limit_exceed?
- rate_limit.remaining <= GITHUB_SAFE_REMAINING_REQUESTS
+ has_rate_limit? && rate_limit.remaining <= GITHUB_SAFE_REMAINING_REQUESTS
end
def rate_limit_sleep_time