Prevent repeated warnings when GitHub API rate limit is exceeded
This commit is contained in:
parent
ee893fdd88
commit
7d4709d9d6
@ -112,7 +112,9 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
results
|
results
|
||||||
rescue GitHub::Error
|
rescue GitHub::RateLimitExceededError => e
|
||||||
|
[]
|
||||||
|
rescue GitHub::Error => e
|
||||||
opoo "Failed to search tap: #{user}/#{repo}. Please run `brew update`"
|
opoo "Failed to search tap: #{user}/#{repo}. Please run `brew update`"
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -252,6 +252,7 @@ module GitHub extend self
|
|||||||
ISSUES_URI = URI.parse("https://api.github.com/legacy/issues/search/Homebrew/homebrew/open/")
|
ISSUES_URI = URI.parse("https://api.github.com/legacy/issues/search/Homebrew/homebrew/open/")
|
||||||
|
|
||||||
Error = Class.new(StandardError)
|
Error = Class.new(StandardError)
|
||||||
|
RateLimitExceededError = Class.new(Error)
|
||||||
|
|
||||||
def open url, headers={}, &block
|
def open url, headers={}, &block
|
||||||
# This is a no-op if the user is opting out of using the GitHub API.
|
# This is a no-op if the user is opting out of using the GitHub API.
|
||||||
@ -266,7 +267,7 @@ module GitHub extend self
|
|||||||
end
|
end
|
||||||
rescue OpenURI::HTTPError => e
|
rescue OpenURI::HTTPError => e
|
||||||
if e.io.meta['x-ratelimit-remaining'].to_i <= 0
|
if e.io.meta['x-ratelimit-remaining'].to_i <= 0
|
||||||
raise Error, <<-EOS.undent, e.backtrace
|
raise RateLimitExceededError, <<-EOS.undent, e.backtrace
|
||||||
GitHub #{Utils::JSON.load(e.io.read)['message']}
|
GitHub #{Utils::JSON.load(e.io.read)['message']}
|
||||||
You may want to create an API token: https://github.com/settings/applications
|
You may want to create an API token: https://github.com/settings/applications
|
||||||
and then set HOMEBREW_GITHUB_API_TOKEN.
|
and then set HOMEBREW_GITHUB_API_TOKEN.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user