aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorMike McQuaid2017-08-15 10:49:47 +0100
committerGitHub2017-08-15 10:49:47 +0100
commit8518ffdee19c0c985e8631e836b78624e4926c7f (patch)
tree339f183fcac9f561732f109f52a2e348b18deac4 /Library/Homebrew/cmd
parent60d8218abfe070de765e7a5737cc7e34735288db (diff)
parent961d79011e0f0b2c63cf33f7818a4f0437e1643e (diff)
downloadbrew-8518ffdee19c0c985e8631e836b78624e4926c7f.tar.bz2
Merge pull request #3059 from MikeMcQuaid/why-search-take-so-long
search: explain why it takes the time it does.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/search.rb10
1 files changed, 10 insertions, 0 deletions
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