Merge pull request #17245 from Homebrew/forbid_install_tap

tap: allow/forbid installation of taps from environment variables.
This commit is contained in:
Mike McQuaid 2024-05-07 11:14:16 +01:00 committed by GitHub
commit 6aeb9cd5d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -445,6 +445,21 @@ class Tap
raise TapAlreadyTappedError, name unless shallow?
end
if !allowed_by_env? || forbidden_by_env?
owner = Homebrew::EnvConfig.forbidden_owner
owner_contact = if (contact = Homebrew::EnvConfig.forbidden_owner_contact.presence)
"\n#{contact}"
end
error_message = +"The installation of the #{full_name} was requested but #{owner}\n"
error_message << "has not allowed this tap in `HOMEBREW_ALLOWED_TAPS`" unless allowed_by_env?
error_message << " and\n" if !allowed_by_env? && forbidden_by_env?
error_message << "has forbidden this tap in `HOMEBREW_FORBIDDEN_TAPS`" if forbidden_by_env?
error_message << ".#{owner_contact}"
odie error_message
end
# ensure git is installed
Utils::Git.ensure_installed!