Merge pull request #15934 from hyuraku/remove-ARGV-from-Formula.all

remove `ARGV` from `Formula#all`
This commit is contained in:
Mike McQuaid 2023-09-02 08:05:34 -04:00 committed by GitHub
commit f71e09251f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 15 deletions

View File

@ -124,7 +124,8 @@ module Homebrew
puts_deps_tree dependents, recursive: recursive, args: args
return
elsif all
puts_deps sorted_dependents(Formula.all + Cask::Cask.all), recursive: recursive, args: args
puts_deps sorted_dependents(Formula.all(eval_all: args.eval_all?) + Cask::Cask.all), recursive: recursive,
args: args
return
elsif !args.no_named? && args.for_each?
puts_deps sorted_dependents(args.named.to_formulae_and_casks), recursive: recursive, args: args

View File

@ -194,7 +194,7 @@ module Homebrew
raise UsageError, "Cannot specify `--cask` when using `--json=v1`!" if args.cask?
formulae = if all
Formula.all.sort
Formula.all(eval_all: args.eval_all?).sort
elsif args.installed?
Formula.installed.sort
else
@ -208,7 +208,7 @@ module Homebrew
end
when :v2
formulae, casks = if all
[Formula.all.sort, Cask::Cask.all.sort_by(&:full_name)]
[Formula.all(eval_all: args.eval_all?).sort, Cask::Cask.all.sort_by(&:full_name)]
elsif args.installed?
[Formula.installed.sort, Cask::Caskroom.casks.sort_by(&:full_name)]
else

View File

@ -35,7 +35,7 @@ module Homebrew
all = args.eval_all?
if all
puts_options Formula.all.sort, args: args
puts_options Formula.all(eval_all: args.eval_all?).sort, args: args
elsif args.installed?
puts_options Formula.installed.sort, args: args
elsif args.command.present?

View File

@ -116,7 +116,7 @@ module Homebrew
end
if show_formulae_and_casks || args.formula?
deps += args.installed? ? Formula.installed : Formula.all
deps += args.installed? ? Formula.installed : Formula.all(eval_all: args.eval_all?)
end
if show_formulae_and_casks || args.cask?
deps += args.installed? ? Cask::Caskroom.casks : Cask::Cask.all

View File

@ -136,7 +136,7 @@ module Homebrew
"brew audit --eval-all or HOMEBREW_EVAL_ALL"
end
no_named_args = true
[Formula.all, Cask::Cask.all]
[Formula.all(eval_all: args.eval_all?), Cask::Cask.all]
else
if args.named.any? { |named_arg| named_arg.end_with?(".rb") }
odisabled "brew audit [path ...]",

View File

@ -85,7 +85,7 @@ module Homebrew
casks = args.formula? ? [] : Cask::Caskroom.casks
formulae + casks
elsif all
formulae = args.cask? ? [] : Formula.all
formulae = args.cask? ? [] : Formula.all(eval_all: args.eval_all?)
casks = args.formula? ? [] : Cask::Cask.all
formulae + casks
elsif args.named.present?

View File

@ -103,11 +103,11 @@ module Homebrew
raise UsageError, "`brew unbottled --dependents` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
end
formulae = all_formulae = Formula.all
formulae = all_formulae = Formula.all(eval_all: args.eval_all?)
@sort = " (sorted by number of dependents)"
elsif all
formulae = all_formulae = Formula.all
formulae = all_formulae = Formula.all(eval_all: args.eval_all?)
else
formula_installs = {}
@ -134,7 +134,7 @@ module Homebrew
end.compact
@sort = " (sorted by installs in the last 90 days; top 10,000 only)"
all_formulae = Formula.all
all_formulae = Formula.all(eval_all: args.eval_all?)
end
[formulae, all_formulae, formula_installs]

View File

@ -31,6 +31,8 @@ require "utils/spdx"
require "extend/on_system"
require "api"
require "extend/api_hashable"
require "cli/parser"
require "commands"
# A formula provides instructions and metadata for Homebrew to install a piece
# of software. Every Homebrew formula is a {Formula}.
@ -1945,11 +1947,8 @@ class Formula
# an array of all {Formula}
# this should only be used when users specify `--all` to a command
# @private
def self.all
# TODO: ideally avoid using ARGV by moving to e.g. CLI::Parser
if ARGV.exclude?("--eval-all") && !Homebrew::EnvConfig.eval_all?
odisabled "Formula#all without --eval-all or HOMEBREW_EVAL_ALL"
end
def self.all(eval_all: false)
odisabled "Formula#all without --eval-all or HOMEBREW_EVAL_ALL" if !eval_all && !Homebrew::EnvConfig.eval_all?
(core_names + tap_files).map do |name_or_file|
Formulary.factory(name_or_file)