edit: add HOMEBREW_NO_INSTALL_FROM_API warning.

This commit is contained in:
Sanjito Kurniawan 2023-02-10 12:07:58 +01:00 committed by Mike McQuaid
parent e0ba9a1249
commit 2daae5e84d
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
2 changed files with 14 additions and 1 deletions

View File

@ -78,6 +78,19 @@ module Homebrew
end.presence
end
if Homebrew::EnvConfig.automatically_set_no_install_from_api? &&
!Homebrew::EnvConfig.no_env_hints?
paths.each do |path|
next if !path.fnmatch?("**/homebrew-core/Formula/*.rb") && !path.fnmatch?("**/homebrew-cask/Casks/*.rb")
opoo <<~EOS
Unless `HOMEBREW_NO_INSTALL_FROM_API` is set when running
`brew install`, it will ignore your locally edited formula.
EOS
break
end
end
if args.print_path?
paths.each(&method(:puts))
return

View File

@ -13,7 +13,7 @@ describe "brew edit" do
setup_test_formula "testball"
expect { brew "edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat" }
expect { brew "edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat", "HOMEBREW_NO_ENV_HINTS" => "1" }
.to output(/# something here/).to_stdout
.and not_to_output.to_stderr
.and be_a_success