Merge pull request #14232 from MikeMcQuaid/brew_search_args

description*: fix argument handling of eval_all.
This commit is contained in:
Mike McQuaid 2022-12-08 10:29:27 +00:00 committed by GitHub
commit 2fb9f9ca13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -101,8 +101,8 @@ class CaskDescriptionCacheStore < DescriptionCacheStore
# If the database is empty `update!` it with all known casks. # If the database is empty `update!` it with all known casks.
# #
# @return [nil] # @return [nil]
def populate_if_empty! def populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?)
return unless Homebrew::EnvConfig.eval_all? return unless eval_all
return unless database.empty? return unless database.empty?
Cask::Cask.all.each { |c| update!(c.full_name, [c.name.join(", "), c.desc.presence]) } Cask::Cask.all.each { |c| update!(c.full_name, [c.name.join(", "), c.desc.presence]) }

View File

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

View File

@ -16,7 +16,8 @@ module Homebrew
ohai "Casks" ohai "Casks"
CacheStoreDatabase.use(:cask_descriptions) do |db| CacheStoreDatabase.use(:cask_descriptions) do |db|
cache_store = CaskDescriptionCacheStore.new(db) cache_store = CaskDescriptionCacheStore.new(db)
Descriptions.search(string_or_regex, :desc, cache_store).print eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all?
Descriptions.search(string_or_regex, :desc, cache_store, eval_all).print
end end
end end

View File

@ -25,7 +25,8 @@ module Homebrew
ohai "Formulae" ohai "Formulae"
CacheStoreDatabase.use(:descriptions) do |db| CacheStoreDatabase.use(:descriptions) do |db|
cache_store = DescriptionCacheStore.new(db) cache_store = DescriptionCacheStore.new(db)
Descriptions.search(string_or_regex, :desc, cache_store).print eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all?
Descriptions.search(string_or_regex, :desc, cache_store, eval_all).print
end end
end end