Handle error when 'brew search' can't reach GitHub

This commit is contained in:
Stevie Howard 2018-04-06 22:12:29 -07:00 committed by GitHub
parent 94c0d833c3
commit 296d48ba7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,8 +111,16 @@ module Homebrew
end end
valid_dirnames = ["Formula", "HomebrewFormula", "Casks", "."].freeze valid_dirnames = ["Formula", "HomebrewFormula", "Casks", "."].freeze
matches = GitHub.search_code(user: ["Homebrew", "caskroom"], filename: query, extension: "rb") matches = begin
GitHub.search_code(
user: ["Homebrew", "caskroom"],
filename: query,
extension: "rb",
)
rescue GitHub::Error => error
opoo "Error searching on GitHub: #{error}\n"
[]
end
matches.map do |match| matches.map do |match|
dirname, filename = File.split(match["path"]) dirname, filename = File.split(match["path"])
next unless valid_dirnames.include?(dirname) next unless valid_dirnames.include?(dirname)