Skip to content

Commit

Permalink
env_config: infer HOMEBREW_FORBID_PACKAGES_FROM_PATHS from HOMEBREW_D…
Browse files Browse the repository at this point in the history
…EVELOPER

If `HOMEBREW_DEVELOPER` is not set, then let's make
`HOMEBREW_FORBID_PACKAGES_FROM_PATHS` default to true.

I used a custom implementation here because we don't currently support
setting defaults for booleans. (See calls to `define_method` below.)

Closes #18371.
  • Loading branch information
carlocab committed Sep 23, 2024
1 parent bd3c7f8 commit ab22e8b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ module EnvConfig
"formula if it or any of its dependencies is in a tap on this list.",
},
HOMEBREW_FORBID_PACKAGES_FROM_PATHS: {
description: "If set, Homebrew will refuse to read formulae or casks provided from file paths, " \
"e.g. `brew install ./package.rb`.",
boolean: true,
description: "If set, Homebrew will refuse to read formulae or casks provided from file paths, " \
"e.g. `brew install ./package.rb`.",
boolean: true,
default_text: "Enabled unless `HOMEBREW_DEVELOPER` is set.",
default: -> { !developer? },
},
HOMEBREW_FORCE_BREWED_CA_CERTIFICATES: {
description: "If set, always use a Homebrew-installed `ca-certificates` rather than the system version. " \
Expand Down Expand Up @@ -504,6 +506,7 @@ def env_method_name(env, hash)
CUSTOM_IMPLEMENTATIONS = T.let(Set.new([
:HOMEBREW_MAKE_JOBS,
:HOMEBREW_CASK_OPTS,
:HOMEBREW_FORBID_PACKAGES_FROM_PATHS,
]).freeze, T::Set[Symbol])

ENVS.each do |env, hash|
Expand All @@ -528,6 +531,15 @@ def env_method_name(env, hash)
end
end

sig { returns(T::Boolean) }
def forbid_packages_from_paths?
return true if ENV["HOMEBREW_FORBID_PACKAGES_FROM_PATHS"].present?

ENVS.fetch(:HOMEBREW_FORBID_PACKAGES_FROM_PATHS)
.fetch(:default)
.call
end

# Needs a custom implementation.
sig { returns(String) }
def make_jobs
Expand Down

0 comments on commit ab22e8b

Please sign in to comment.