Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env_config: infer HOMEBREW_FORBID_PACKAGES_FROM_PATHS from HOMEBREW_DEVELOPER #18379

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +538 to +540
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ENVS.fetch(:HOMEBREW_FORBID_PACKAGES_FROM_PATHS)
.fetch(:default)
.call
developer?

feels a bit nice?

end

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