Merge pull request #4027 from SENG480-18/master
Simplify `search_taps` method and handle errors
This commit is contained in:
commit
c73e873893
@ -108,15 +108,22 @@ module Homebrew
|
||||
$stderr.puts Formatter.headline("Searching taps on GitHub...", color: :blue)
|
||||
end
|
||||
|
||||
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"],
|
||||
path: ["Formula", "HomebrewFormula", "Casks", "."],
|
||||
filename: query,
|
||||
extension: "rb",
|
||||
)
|
||||
rescue GitHub::Error => error
|
||||
opoo "Error searching on GitHub: #{error}\n"
|
||||
[]
|
||||
end
|
||||
matches.map do |match|
|
||||
dirname, filename = File.split(match["path"])
|
||||
next unless valid_dirnames.include?(dirname)
|
||||
filename = File.basename(match["path"], ".rb")
|
||||
tap = Tap.fetch(match["repository"]["full_name"])
|
||||
next if tap.installed? && match["repository"]["owner"]["login"] != "caskroom"
|
||||
"#{tap.name}/#{File.basename(filename, ".rb")}"
|
||||
"#{tap.name}/#{filename}"
|
||||
end.compact
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user