Deprecate invoking commands in the old style

This commit is contained in:
Douglas Eichelberger 2024-08-09 17:35:40 -07:00
parent 102dec893b
commit 4fd659797f
2 changed files with 10 additions and 0 deletions

View File

@ -167,6 +167,14 @@ module Homebrew
@command_name = T.let(T.must(cmd_location.label).chomp("_args").tr("_", "-"), String) @command_name = T.let(T.must(cmd_location.label).chomp("_args").tr("_", "-"), String)
@is_dev_cmd = T.let(T.must(cmd_location.absolute_path).start_with?(Commands::HOMEBREW_DEV_CMD_PATH), @is_dev_cmd = T.let(T.must(cmd_location.absolute_path).start_with?(Commands::HOMEBREW_DEV_CMD_PATH),
T::Boolean) T::Boolean)
# We allow this path only from `brew.rb`:
if @command_name != "<main>"
odeprecated(
"`brew #{@command_name}', which does not inherit from from Homebrew::AbstractCommand. This command " \
"needs to be refactored, as it is written in a style that",
disable_for_developers: false,
)
end
end end
@constraints = T.let([], T::Array[[String, String]]) @constraints = T.let([], T::Array[[String, String]])

View File

@ -172,11 +172,13 @@ module Kernel
disable = true if disable_for_developers && Homebrew::EnvConfig.developer? disable = true if disable_for_developers && Homebrew::EnvConfig.developer?
if disable || Homebrew.raise_deprecation_exceptions? if disable || Homebrew.raise_deprecation_exceptions?
require "utils/github/actions"
GitHub::Actions.puts_annotation_if_env_set(:error, message, file:, line:) GitHub::Actions.puts_annotation_if_env_set(:error, message, file:, line:)
exception = MethodDeprecatedError.new(message) exception = MethodDeprecatedError.new(message)
exception.set_backtrace(backtrace) exception.set_backtrace(backtrace)
raise exception raise exception
elsif !Homebrew.auditing? elsif !Homebrew.auditing?
require "utils/github/actions"
GitHub::Actions.puts_annotation_if_env_set(:warning, message, file:, line:) GitHub::Actions.puts_annotation_if_env_set(:warning, message, file:, line:)
opoo message opoo message
end end