aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/search.rb10
-rw-r--r--Library/Homebrew/test/cmd/search_spec.rb6
2 files changed, 13 insertions, 3 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
diff --git a/Library/Homebrew/test/cmd/search_spec.rb b/Library/Homebrew/test/cmd/search_spec.rb
index 7c97e6e35..77c2c6352 100644
--- a/Library/Homebrew/test/cmd/search_spec.rb
+++ b/Library/Homebrew/test/cmd/search_spec.rb
@@ -14,7 +14,7 @@ describe "brew search", :integration_test do
it "supports searching by name" do
expect { brew "search", "testball" }
.to output(/testball/).to_stdout
- .and not_to_output.to_stderr
+ .and output(/Searching/).to_stderr
.and be_a_success
end
@@ -25,10 +25,10 @@ describe "brew search", :integration_test do
.and be_a_success
end
- it "falls back to a tap search when no formula is found" do
+ it "falls back to a GitHub tap search when no formula is found", :needs_network do
expect { brew "search", "caskroom/cask/firefox" }
.to output(/firefox/).to_stdout
- .and not_to_output.to_stderr
+ .and output(/Searching/).to_stderr
.and be_a_success
end