cmd/desc: fix searching.

Ensure that the cache store is populated if we pass `--eval-all`.
This commit is contained in:
Mike McQuaid 2022-12-06 13:56:54 +00:00
parent 001bacee18
commit 28719f7fdc
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
3 changed files with 7 additions and 6 deletions

View File

@ -72,11 +72,12 @@ module Homebrew
else
query = args.named.join(" ")
string_or_regex = query_regexp(query)
eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all?
unless args.cask?
ohai "Formulae"
CacheStoreDatabase.use(:descriptions) do |db|
cache_store = DescriptionCacheStore.new(db)
Descriptions.search(string_or_regex, search_type, cache_store).print
Descriptions.search(string_or_regex, search_type, cache_store, eval_all).print
end
end
unless args.formula?
@ -84,7 +85,7 @@ module Homebrew
ohai "Casks"
CacheStoreDatabase.use(:cask_descriptions) do |db|
cache_store = CaskDescriptionCacheStore.new(db)
Descriptions.search(string_or_regex, search_type, cache_store).print
Descriptions.search(string_or_regex, search_type, cache_store, eval_all).print
end
end
end

View File

@ -33,8 +33,8 @@ class DescriptionCacheStore < CacheStore
# If the database is empty `update!` it with all known formulae.
#
# @return [nil]
def populate_if_empty!
return unless Homebrew::EnvConfig.eval_all?
def populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?)
return unless eval_all
return unless database.empty?
Formula.all.each { |f| update!(f.full_name, f.desc) }

View File

@ -13,8 +13,8 @@ class Descriptions
extend Homebrew::Search
# Given a regex, find all formulae whose specified fields contain a match.
def self.search(string_or_regex, field, cache_store)
cache_store.populate_if_empty!
def self.search(string_or_regex, field, cache_store, eval_all)
cache_store.populate_if_empty!(eval_all: eval_all)
results = case field
when :name