aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorDaniel Lee Harple2013-05-14 10:42:46 -0400
committerJack Nagel2013-05-22 19:53:04 -0500
commit0fa5c47d7fa15d677f4604d60223d4db2c52e369 (patch)
treef77d69f6a2fa02fa39965bb161e8b76b881accdb /Library/Homebrew/cmd
parent222f96d37b3c41b0538e96245ab37c6f01b872c2 (diff)
downloadbrew-0fa5c47d7fa15d677f4604d60223d4db2c52e369.tar.bz2
Check GitHub API rate limit instead of silently failing
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/search.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index 4ae2f314a..2ceefd2ce 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -64,18 +64,19 @@ module Homebrew extend self
results = []
GitHub.open "https://api.github.com/repos/#{user}/homebrew-#{repo}/git/trees/HEAD?recursive=1" do |f|
- user.downcase! if user == "Homebrew" # special handling for the Homebrew organization
- MultiJson.decode(f.read)["tree"].map{ |hash| hash['path'] }.compact.each do |file|
- name = File.basename(file, '.rb')
- if file =~ /\.rb$/ and name =~ rx
- results << "#{user}/#{repo}/#{name}"
- $found += 1
+ begin
+ user.downcase! if user == "Homebrew" # special handling for the Homebrew organization
+ MultiJson.decode(f.read)["tree"].map{ |hash| hash['path'] }.compact.each do |file|
+ name = File.basename(file, '.rb')
+ if file =~ /\.rb$/ and name =~ rx
+ results << "#{user}/#{repo}/#{name}"
+ $found += 1
+ end
end
+ rescue
end
end
results
- rescue
- []
end
def search_brews rx