Merge pull request #20331 from Homebrew/deprecate_disable_remove_4.6

Deprecate/disable/remove code for Homebrew 4.6
This commit is contained in:
Mike McQuaid 2025-07-31 11:40:29 +00:00 committed by GitHub
commit 8217fe5bcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 22 additions and 215 deletions

View File

@ -13,7 +13,7 @@ module Homebrew
def self.images def self.images
return [] unless Bundle.whalebrew_installed? return [] unless Bundle.whalebrew_installed?
odeprecated "`brew bundle` `whalebrew` support", "using `whalebrew` directly" odisabled "`brew bundle` `whalebrew` support", "using `whalebrew` directly"
@images ||= T.let( @images ||= T.let(
`whalebrew list 2>/dev/null`.split("\n") `whalebrew list 2>/dev/null`.split("\n")
.reject { |line| line.start_with?("COMMAND ") } .reject { |line| line.start_with?("COMMAND ") }

View File

@ -24,7 +24,7 @@ module Homebrew
end end
def self.install!(name, preinstall: true, verbose: false, force: false, **_options) def self.install!(name, preinstall: true, verbose: false, force: false, **_options)
odeprecated "`brew bundle` `whalebrew` support", "using `whalebrew` directly" odisabled "`brew bundle` `whalebrew` support", "using `whalebrew` directly"
return true unless preinstall return true unless preinstall
puts "Installing #{name} image. It is not currently installed." if verbose puts "Installing #{name} image. It is not currently installed." if verbose

View File

@ -324,7 +324,6 @@ module Cask
return if cask.deprecated? || cask.disabled? return if cask.deprecated? || cask.disabled?
return if cask.version&.latest? return if cask.version&.latest?
return if (url = cask.url).nil? return if (url = cask.url).nil?
return if block_url_offline?
return if cask.livecheck_defined? return if cask.livecheck_defined?
return if livecheck_result == :auto_detected return if livecheck_result == :auto_detected
@ -348,7 +347,6 @@ module Cask
sig { void } sig { void }
def audit_download_url_format def audit_download_url_format
return if (url = cask.url).nil? return if (url = cask.url).nil?
return if block_url_offline?
odebug "Auditing URL format" odebug "Auditing URL format"
return unless bad_sourceforge_url? return unless bad_sourceforge_url?
@ -360,7 +358,6 @@ module Cask
sig { void } sig { void }
def audit_download_url_is_osdn def audit_download_url_is_osdn
return if (url = cask.url).nil? return if (url = cask.url).nil?
return if block_url_offline?
return unless bad_osdn_url? return unless bad_osdn_url?
add_error "OSDN download urls are disabled.", location: url.location, strict_only: true add_error "OSDN download urls are disabled.", location: url.location, strict_only: true
@ -372,7 +369,6 @@ module Cask
sig { void } sig { void }
def audit_unnecessary_verified def audit_unnecessary_verified
return unless cask.url return unless cask.url
return if block_url_offline?
return unless verified_present? return unless verified_present?
return unless url_match_homepage? return unless url_match_homepage?
return unless verified_matches_url? return unless verified_matches_url?
@ -385,7 +381,6 @@ module Cask
sig { void } sig { void }
def audit_missing_verified def audit_missing_verified
return unless cask.url return unless cask.url
return if block_url_offline?
return if file_url? return if file_url?
return if url_match_homepage? return if url_match_homepage?
return if verified_present? return if verified_present?
@ -398,7 +393,6 @@ module Cask
sig { void } sig { void }
def audit_no_match def audit_no_match
return if (url = cask.url).nil? return if (url = cask.url).nil?
return if block_url_offline?
return unless verified_present? return unless verified_present?
return if verified_matches_url? return if verified_matches_url?
@ -1191,13 +1185,6 @@ module Cask
URI(cask.url.to_s).scheme == "file" URI(cask.url.to_s).scheme == "file"
end end
sig { returns(T::Boolean) }
def block_url_offline?
return false if online?
!!cask.url&.from_block?
end
sig { returns(Tap) } sig { returns(Tap) }
def core_tap def core_tap
@core_tap ||= T.let(CoreTap.instance, T.nilable(Tap)) @core_tap ||= T.let(CoreTap.instance, T.nilable(Tap))

View File

@ -98,10 +98,9 @@ module Cask
:disable_reason, :disable_reason,
:disable_replacement_cask, :disable_replacement_cask,
:disable_replacement_formula, :disable_replacement_formula,
:discontinued?, # TODO: remove once discontinued? is removed (4.5.0)
:livecheck, :livecheck,
:livecheck_defined?, :livecheck_defined?,
:livecheckable?, # TODO: remove once `#livecheckable?` is removed :livecheckable?, # TODO: remove once `#livecheckable?` was odisabled and is now removed
:no_autobump!, :no_autobump!,
:autobump?, :autobump?,
:no_autobump_message, :no_autobump_message,
@ -556,7 +555,7 @@ module Cask
# for `#livecheck_defined?`. # for `#livecheck_defined?`.
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def livecheckable? def livecheckable?
odeprecated "`livecheckable?`", "`livecheck_defined?`" odisabled "`livecheckable?`", "`livecheck_defined?`"
@livecheck_defined == true @livecheck_defined == true
end end

View File

@ -7,10 +7,6 @@ require "utils/curl"
module Cask module Cask
# Class corresponding to the `url` stanza. # Class corresponding to the `url` stanza.
class URL < SimpleDelegator class URL < SimpleDelegator
BlockReturn = T.type_alias do
T.any(URI::Generic, String, [T.any(URI::Generic, String), T::Hash[Symbol, T.untyped]])
end
# Methods for the `url` stanza. # Methods for the `url` stanza.
class DSL class DSL
sig { returns(T.any(URI::Generic, String)) } sig { returns(T.any(URI::Generic, String)) }
@ -102,96 +98,6 @@ module Cask
end end
end end
# Allow passing a block to the `url` stanza.
class BlockDSL
# Allow accessing the URL associated with page contents.
class PageWithURL < SimpleDelegator
# Get the URL of the fetched page.
#
# ### Example
#
# ```ruby
# url "https://example.org/download" do |page|
# file_path = page[/href="([^"]+\.dmg)"/, 1]
# URI.join(page.url, file_path)
# end
# ```
#
# @api public
sig { returns(URI::Generic) }
attr_accessor :url
sig { params(str: String, url: URI::Generic).void }
def initialize(str, url)
super(str)
@url = T.let(url, URI::Generic)
end
end
sig {
params(
uri: T.nilable(T.any(URI::Generic, String)),
dsl: ::Cask::DSL,
block: T.proc.params(arg0: T.all(String, PageWithURL)).returns(BlockReturn),
).void
}
def initialize(uri, dsl:, &block)
@uri = T.let(uri, T.nilable(T.any(URI::Generic, String)))
@dsl = T.let(dsl, ::Cask::DSL)
@block = T.let(block, T.proc.params(arg0: T.all(String, PageWithURL)).returns(BlockReturn))
odisabled "cask `url do` blocks" if @block
end
sig { returns(BlockReturn) }
def call
if @uri
result = ::Utils::Curl.curl_output("--fail", "--silent", "--location", @uri.to_s)
result.assert_success!
page = PageWithURL.new(result.stdout, URI(@uri))
instance_exec(page, &@block)
else
instance_exec(&@block)
end
end
private
# Allows calling a nested `url` stanza in a `url do` block.
#
# @api public
sig {
params(
uri: T.any(URI::Generic, String),
block: T.proc.params(arg0: T.all(String, PageWithURL)).returns(BlockReturn),
).returns(BlockReturn)
}
def url(uri, &block)
self.class.new(uri, dsl: @dsl, &block).call
end
# This allows calling DSL methods from inside a `url` block.
#
# @api public
sig {
override.params(method: Symbol, args: T.untyped, block: T.nilable(T.proc.returns(T.untyped)))
.returns(T.anything)
}
def method_missing(method, *args, &block)
if @dsl.respond_to?(method)
@dsl.public_send(method, *args, &block)
else
super
end
end
sig { override.params(method_name: T.any(Symbol, String), include_private: T::Boolean).returns(T::Boolean) }
def respond_to_missing?(method_name, include_private = false)
@dsl.respond_to?(method_name, include_private) || super
end
end
sig { sig {
params( params(
uri: T.nilable(T.any(URI::Generic, String)), uri: T.nilable(T.any(URI::Generic, String)),
@ -210,28 +116,18 @@ module Cask
only_path: T.nilable(String), only_path: T.nilable(String),
caller_location: Thread::Backtrace::Location, caller_location: Thread::Backtrace::Location,
dsl: T.nilable(::Cask::DSL), dsl: T.nilable(::Cask::DSL),
block: T.nilable(T.proc.params(arg0: T.all(String, BlockDSL::PageWithURL)).returns(BlockReturn)),
).void ).void
} }
def initialize( def initialize(
uri = nil, verified: nil, using: nil, tag: nil, branch: nil, revisions: nil, revision: nil, trust_cert: nil, uri = nil, verified: nil, using: nil, tag: nil, branch: nil, revisions: nil, revision: nil, trust_cert: nil,
cookies: nil, referer: nil, header: nil, user_agent: nil, data: nil, only_path: nil, cookies: nil, referer: nil, header: nil, user_agent: nil, data: nil, only_path: nil,
caller_location: caller_locations.fetch(0), dsl: nil, &block caller_location: caller_locations.fetch(0), dsl: nil
) )
super( super(
if block DSL.new(T.must(uri), verified:, using:, tag:, branch:, revisions:, revision:, trust_cert:, cookies:,
LazyObject.new do referer:, header:, user_agent:, data:, only_path:)
uri2, options = *BlockDSL.new(uri, dsl: T.must(dsl), &block).call
options ||= {}
DSL.new(uri2, **options)
end
else
DSL.new(T.must(uri), verified:, using:, tag:, branch:, revisions:, revision:, trust_cert:, cookies:,
referer:, header:, user_agent:, data:, only_path:)
end
) )
@from_block = T.let(!block.nil?, T::Boolean)
@caller_location = T.let(caller_location, Thread::Backtrace::Location) @caller_location = T.let(caller_location, Thread::Backtrace::Location)
end end
@ -252,11 +148,6 @@ module Cask
interpolated_url.exclude?('#{') interpolated_url.exclude?('#{')
end end
sig { returns(T::Boolean) }
def from_block?
@from_block
end
private private
sig { returns(T.nilable(String)) } sig { returns(T.nilable(String)) }

View File

@ -58,7 +58,6 @@ module Homebrew
hidden: true hidden: true
switch "--[no-]signing", switch "--[no-]signing",
description: "Audit for app signatures, which are required by macOS on ARM." description: "Audit for app signatures, which are required by macOS on ARM."
# should be odeprecated in future
switch "--token-conflicts", switch "--token-conflicts",
description: "Audit for token conflicts.", description: "Audit for token conflicts.",
hidden: true hidden: true
@ -105,6 +104,8 @@ module Homebrew
sig { override.void } sig { override.void }
def run def run
odeprecated "brew audit --token-conflicts" if args.token_conflicts?
Formulary.enable_factory_cache! Formulary.enable_factory_cache!
os_arch_combinations = args.os_arch_combinations os_arch_combinations = args.os_arch_combinations

View File

@ -439,20 +439,5 @@ class Pathname
.encode(Encoding::UTF_8, invalid: :replace) .encode(Encoding::UTF_8, invalid: :replace)
.split("\n") .split("\n")
end end
# Like regular `rmtree`, except it never ignores errors.
#
# This was the default behaviour in Ruby 3.1 and earlier.
#
# @api public
def rmtree(noop: nil, verbose: nil, secure: nil)
# Ideally we'd odeprecate this but probably can't given gems so let's
# create a RuboCop autocorrect instead soon.
# This is why monkeypatching is non-ideal (but right solution to get
# Ruby 3.3 over the line).
odisabled "rmtree", "FileUtils#rm_r"
FileUtils.rm_r(T.must(@path), noop:, verbose:, secure:)
nil
end
end end
require "extend/os/pathname" require "extend/os/pathname"

View File

@ -7,7 +7,7 @@ class Time
# Backwards compatibility for formulae that used this ActiveSupport extension # Backwards compatibility for formulae that used this ActiveSupport extension
sig { returns(String) } sig { returns(String) }
def rfc3339 def rfc3339
odeprecated "Time#rfc3339", "Time#xmlschema" odisabled "Time#rfc3339", "Time#xmlschema"
xmlschema xmlschema
end end
end end

View File

@ -2796,24 +2796,6 @@ class Formula
self.class.on_system_blocks_exist? || @on_system_blocks_exist self.class.on_system_blocks_exist? || @on_system_blocks_exist
end end
sig {
params(
verify_download_integrity: T::Boolean,
timeout: T.nilable(T.any(Integer, Float)),
quiet: T::Boolean,
).returns(Pathname)
}
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
odisabled "Formula#fetch", "Resource#fetch on Formula#resource"
active_spec.fetch(verify_download_integrity:, timeout:, quiet:)
end
sig { params(filename: T.any(Pathname, String)).void }
def verify_download_integrity(filename)
odisabled "Formula#verify_download_integrity", "Resource#verify_download_integrity on Formula#resource"
active_spec.verify_download_integrity(filename)
end
sig { params(keep_tmp: T::Boolean).returns(T.untyped) } sig { params(keep_tmp: T::Boolean).returns(T.untyped) }
def run_test(keep_tmp: false) def run_test(keep_tmp: false)
@prefix_returns_versioned_prefix = T.let(true, T.nilable(T::Boolean)) @prefix_returns_versioned_prefix = T.let(true, T.nilable(T::Boolean))
@ -2909,22 +2891,15 @@ class Formula
# @api public # @api public
sig { sig {
params( params(
paths: T.any(T::Enumerable[T.any(String, Pathname)], String, Pathname), paths: T.any(T::Enumerable[T.any(String, Pathname)], String, Pathname),
before: T.nilable(T.any(Pathname, Regexp, String)), before: T.nilable(T.any(Pathname, Regexp, String)),
after: T.nilable(T.any(Pathname, String, Symbol)), after: T.nilable(T.any(Pathname, String, Symbol)),
old_audit_result: T.nilable(T::Boolean), audit_result: T::Boolean,
audit_result: T::Boolean, global: T::Boolean,
global: T::Boolean, block: T.nilable(T.proc.params(s: StringInreplaceExtension).void),
block: T.nilable(T.proc.params(s: StringInreplaceExtension).void),
).void ).void
} }
def inreplace(paths, before = nil, after = nil, old_audit_result = nil, audit_result: true, global: true, &block) def inreplace(paths, before = nil, after = nil, audit_result: true, global: true, &block)
# NOTE: must check for `#nil?` and not `#blank?`, or else `old_audit_result = false` will not call `odeprecated`.
unless old_audit_result.nil?
odisabled "inreplace(paths, before, after, #{old_audit_result})",
"inreplace(paths, before, after, audit_result: #{old_audit_result})"
audit_result = old_audit_result
end
Utils::Inreplace.inreplace(paths, before, after, audit_result:, global:, &block) Utils::Inreplace.inreplace(paths, before, after, audit_result:, global:, &block)
rescue Utils::Inreplace::Error => e rescue Utils::Inreplace::Error => e
onoe e.to_s onoe e.to_s
@ -3558,7 +3533,7 @@ class Formula
# and `false` otherwise. # and `false` otherwise.
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def livecheckable? def livecheckable?
odeprecated "`livecheckable?`", "`livecheck_defined?`" odisabled "`livecheckable?`", "`livecheck_defined?`"
@livecheck_defined == true @livecheck_defined == true
end end

View File

@ -20,13 +20,6 @@ class GitRepository
pathname.join(".git").exist? pathname.join(".git").exist?
end end
sig { returns(T::Boolean) }
def git_repo?
# delete this whole function when removing odisabled
odisabled "GitRepository#git_repo?", "GitRepository#git_repository?"
git_repository?
end
# Gets the URL of the Git origin remote. # Gets the URL of the Git origin remote.
sig { returns(T.nilable(String)) } sig { returns(T.nilable(String)) }
def origin_url def origin_url

View File

@ -182,7 +182,7 @@ class Resource
# and `false` otherwise. # and `false` otherwise.
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def livecheckable? def livecheckable?
odeprecated "`livecheckable?`", "`livecheck_defined?`" odisabled "`livecheckable?`", "`livecheck_defined?`"
@livecheck_defined == true @livecheck_defined == true
end end

View File

@ -155,14 +155,6 @@ class Tap
# @api public # @api public
attr_reader :repository attr_reader :repository
# @deprecated
sig { returns(T::Boolean) }
def repo
# delete this whole function when removing odisabled
odisabled "Tap#repo", "Tap#repository"
repository
end
# The name of this {Tap}. It combines {#user} and {#repository} with a slash. # The name of this {Tap}. It combines {#user} and {#repository} with a slash.
# {#name} is always in lowercase. # {#name} is always in lowercase.
# e.g. `user/repository` # e.g. `user/repository`
@ -277,14 +269,6 @@ class Tap
@remote_repository ||= T.must(match[:remote_repository]) @remote_repository ||= T.must(match[:remote_repository])
end end
# @deprecated
sig { returns(T.nilable(String)) }
def remote_repo
# delete this whole function when removing odisabled
odisabled "Tap#remote_repo", "Tap#remote_repository"
remote_repository
end
# The default remote path to this {Tap}. # The default remote path to this {Tap}.
sig { returns(String) } sig { returns(String) }
def default_remote def default_remote
@ -299,14 +283,6 @@ class Tap
.upcase .upcase
end end
# @deprecated
sig { returns(String) }
def repo_var_suffix
# delete this whole function when removing odisabled
odisabled "Tap#repo_var_suffix", "Tap#repository_var_suffix"
repository_var_suffix
end
# Check whether this {Tap} is a Git repository. # Check whether this {Tap} is a Git repository.
# #
# @api public # @api public

View File

@ -37,10 +37,10 @@ class StringInreplaceExtension
).returns(T.nilable(String)) ).returns(T.nilable(String))
} }
def gsub!(before, after, old_audit_result = nil, audit_result: true) def gsub!(before, after, old_audit_result = nil, audit_result: true)
# NOTE: must check for `#nil?` and not `#blank?`, or else `old_audit_result = false` will not call `odeprecated`. # NOTE: must check for `#nil?` and not `#blank?`, or else `old_audit_result = false` will not call `odisabled`.
unless old_audit_result.nil? unless old_audit_result.nil?
odeprecated "gsub!(before, after, #{old_audit_result})", odisabled "gsub!(before, after, #{old_audit_result})",
"gsub!(before, after, audit_result: #{old_audit_result})" "gsub!(before, after, audit_result: #{old_audit_result})"
audit_result = old_audit_result audit_result = old_audit_result
end end
before = before.to_s if before.is_a?(Pathname) before = before.to_s if before.is_a?(Pathname)