Scope HOMEBREW_NO_INSTALL_FROM_API to core formulae in brew audit
This commit is contained in:
parent
041545db2c
commit
559bec95bc
@ -790,7 +790,6 @@ then
|
|||||||
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
|
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
|
||||||
then
|
then
|
||||||
NO_INSTALL_FROM_API_COMMANDS=(
|
NO_INSTALL_FROM_API_COMMANDS=(
|
||||||
audit
|
|
||||||
bottle
|
bottle
|
||||||
bump-cask-pr
|
bump-cask-pr
|
||||||
bump-formula-pr
|
bump-formula-pr
|
||||||
|
|||||||
@ -122,7 +122,8 @@ module Homebrew
|
|||||||
ENV.activate_extensions!
|
ENV.activate_extensions!
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment
|
||||||
|
|
||||||
audit_formulae, audit_casks = if args.tap
|
audit_formulae, audit_casks = without_api do # audit requires full Ruby source
|
||||||
|
if args.tap
|
||||||
Tap.fetch(args.tap).then do |tap|
|
Tap.fetch(args.tap).then do |tap|
|
||||||
[
|
[
|
||||||
tap.formula_names.map { |name| Formula[name] },
|
tap.formula_names.map { |name| Formula[name] },
|
||||||
@ -148,6 +149,7 @@ module Homebrew
|
|||||||
args.named.to_formulae_and_casks
|
args.named.to_formulae_and_casks
|
||||||
.partition { |formula_or_cask| formula_or_cask.is_a?(Formula) }
|
.partition { |formula_or_cask| formula_or_cask.is_a?(Formula) }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if audit_formulae.empty? && audit_casks.empty?
|
if audit_formulae.empty? && audit_casks.empty?
|
||||||
ofail "No matching formulae or casks to audit!"
|
ofail "No matching formulae or casks to audit!"
|
||||||
@ -209,8 +211,15 @@ module Homebrew
|
|||||||
display_cop_names: args.display_cop_names?,
|
display_cop_names: args.display_cop_names?,
|
||||||
}.compact
|
}.compact
|
||||||
|
|
||||||
fa = FormulaAuditor.new(f, **options)
|
audit_proc = proc { FormulaAuditor.new(f, **options).tap(&:audit) }
|
||||||
fa.audit
|
|
||||||
|
# Audit requires full Ruby source so disable API.
|
||||||
|
# We shouldn't do this for taps however so that we don't unnecessarily require a full Homebrew/core clone.
|
||||||
|
fa = if f.core_formula?
|
||||||
|
without_api(&audit_proc)
|
||||||
|
else
|
||||||
|
audit_proc.call
|
||||||
|
end
|
||||||
|
|
||||||
if fa.problems.any? || fa.new_formula_problems.any?
|
if fa.problems.any? || fa.new_formula_problems.any?
|
||||||
formula_count += 1
|
formula_count += 1
|
||||||
@ -316,4 +325,10 @@ module Homebrew
|
|||||||
def format_problem(message, location)
|
def format_problem(message, location)
|
||||||
"* #{location&.to_s&.dup&.concat(": ")}#{message.chomp.gsub("\n", "\n ")}"
|
"* #{location&.to_s&.dup&.concat(": ")}#{message.chomp.gsub("\n", "\n ")}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def without_api(&block)
|
||||||
|
return yield unless Homebrew::EnvConfig.install_from_api?
|
||||||
|
|
||||||
|
with_env(HOMEBREW_NO_INSTALL_FROM_API: "1", HOMEBREW_AUTOMATICALLY_SET_NO_INSTALL_FROM_API: "1", &block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user