brew search will search taps we decide are core

This means `brew search` always does some network operations. Which is a shame, but I think (for brew) fine. Probably the no-connectivity handling needs to be improved.
This commit is contained in:
Max Howell 2012-03-16 22:37:11 +00:00
parent 93ef27c808
commit 4d53e2f169

View File

@ -28,13 +28,38 @@ module Homebrew extend self
puts msg puts msg
end end
if search_results.empty? and not blacklisted? query $found = search_results.length
puts_columns search_tap "adamv", "alt", rx
puts_columns search_tap "josegonzalez", "php", rx
if $found == 0 and not blacklisted? query
puts "No formula found for \"#{query}\". Searching open pull requests..." puts "No formula found for \"#{query}\". Searching open pull requests..."
GitHub.find_pull_requests(rx) { |pull| puts pull } GitHub.find_pull_requests(rx) { |pull| puts pull }
end end
end end
end end
def search_tap user, repo, rx
return [] if (HOMEBREW_LIBRARY/"Taps/#{user}-#{repo}").directory?
require 'open-uri'
require 'yaml'
results = []
open "http://github.com/api/v2/yaml/blob/all/#{user}/homebrew-#{repo}/master" do |f|
YAML::load(f.read)["blobs"].each do |file, _|
name = File.basename(file, '.rb')
if file =~ /\.rb$/ and name =~ rx
results << "#{user}/#{repo}/#{name}"
$found += 1
end
end
end
results
rescue
[]
end
def search_brews rx def search_brews rx
if rx.to_s.empty? if rx.to_s.empty?
Formula.names Formula.names