From 961d79011e0f0b2c63cf33f7818a4f0437e1643e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 15 Aug 2017 10:25:51 +0100 Subject: search: explain why it takes the time it does. Provide a bit of clarity that this isn't just searching a local database but doing an GitHub API and Git history query. --- Library/Homebrew/cmd/search.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 0d47f8ab1..53767e75f 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -58,12 +58,14 @@ module Homebrew regex = query_regexp(query) local_results = search_formulae(regex) puts Formatter.columns(local_results) unless local_results.empty? + tap_results = search_taps(query) puts Formatter.columns(tap_results) unless tap_results.empty? if $stdout.tty? count = local_results.length + tap_results.length + ohai "Searching blacklisted, migrated and deleted formulae..." if reason = Homebrew::MissingFormula.reason(query, silent: true) if count > 0 puts @@ -101,6 +103,11 @@ module Homebrew end def search_taps(query) + return [] if ENV["HOMEBREW_NO_GITHUB_API"] + + # Use stderr to avoid breaking parsed output + $stderr.puts Formatter.headline("Searching taps on GitHub...", color: :blue) + valid_dirnames = ["Formula", "HomebrewFormula", "Casks", "."].freeze matches = GitHub.search_code("user:Homebrew", "user:caskroom", "filename:#{query}", "extension:rb") [*matches].map do |match| @@ -113,6 +120,9 @@ module Homebrew end def search_formulae(regex) + # Use stderr to avoid breaking parsed output + $stderr.puts Formatter.headline("Searching local taps...", color: :blue) + aliases = Formula.alias_full_names results = (Formula.full_names + aliases).grep(regex).sort -- cgit v1.2.3