Skip to content

Commit

Permalink
Merge pull request #18408 from Homebrew/falsy-env_config
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocab authored Sep 25, 2024
2 parents e030625 + 78065c5 commit 7d23111
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,18 @@ def env_method_name(env, hash)

if hash[:boolean]
define_method(method_name) do
ENV[env].present?
env_value = ENV.fetch(env, nil)

falsy_values = %w[false no off nil 0]
if falsy_values.include?(env_value&.downcase)
odeprecated "#{env}=#{env_value}", <<~EOS
If you wish to enable #{env}, #{env}=1
If you wish to disable #{env}, #{env}=
EOS
end

# TODO: Uncomment the remaining part of the line below after the deprecation/disable cycle.
env_value.present? # && !falsy_values.include(env_value.downcase)
end
elsif hash[:default].present?
define_method(method_name) do
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/test/github_runner_matrix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_LONG_TIMEOUT", "false").and_return("false")
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER", "false").and_return("false")
allow(ENV).to receive(:fetch).with("GITHUB_RUN_ID").and_return("12345")
allow(ENV).to receive(:fetch).with("HOMEBREW_NO_INSTALL_FROM_API", nil).and_call_original
allow(ENV).to receive(:fetch).with("HOMEBREW_EVAL_ALL", nil).and_call_original
allow(ENV).to receive(:fetch).with("HOMEBREW_SIMULATE_MACOS_ON_LINUX", nil).and_call_original
allow(ENV).to receive(:fetch).with("HOMEBREW_FORBID_PACKAGES_FROM_PATHS", nil).and_call_original
end

let(:newest_supported_macos) do
Expand Down

0 comments on commit 7d23111

Please sign in to comment.