Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
24cbb4fd
Commit
24cbb4fd
authored
11 years ago
by
Jack Nagel
Browse files
Options
Downloads
Patches
Plain Diff
Add a more useful message when ratelimit is exceeded
parent
f7cda3cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/utils.rb
+13
-2
13 additions, 2 deletions
Library/Homebrew/utils.rb
with
13 additions
and
2 deletions
Library/Homebrew/utils.rb
+
13
−
2
View file @
24cbb4fd
...
...
@@ -280,10 +280,13 @@ module GitHub extend self
end
def
handle_api_error
(
e
)
if
e
.
io
.
meta
[
'x-ratelimit-remaining'
].
to_i
<=
0
if
e
.
io
.
meta
[
"x-ratelimit-remaining"
].
to_i
<=
0
reset
=
e
.
io
.
meta
.
fetch
(
"x-ratelimit-reset"
).
to_i
raise
RateLimitExceededError
,
<<-
EOS
.
undent
,
e
.
backtrace
GitHub
#{
Utils
::
JSON
.
load
(
e
.
io
.
read
)[
'message'
]
}
You may want to create an API token: https://github.com/settings/applications
Try again in
#{
pretty_ratelimit_reset
(
reset
)
}
, or create an API token:
https://github.com/settings/applications
and then set HOMEBREW_GITHUB_API_TOKEN.
EOS
end
...
...
@@ -298,6 +301,14 @@ module GitHub extend self
end
end
def
pretty_ratelimit_reset
(
reset
)
if
(
seconds
=
Time
.
at
(
reset
)
-
Time
.
now
)
>
180
"%d minutes %d seconds"
%
[
seconds
/
60
,
seconds
%
60
]
else
"
#{
seconds
}
seconds"
end
end
def
issues_matching
(
query
,
qualifiers
=
{})
uri
=
ISSUES_URI
.
dup
uri
.
query
=
build_query_string
(
query
,
qualifiers
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment