Skip to content

Commit

Permalink
Add new odeprecated, odisabled, remove disabled code.
Browse files Browse the repository at this point in the history
Prepare the usual deprecation cycle for Homebrew 4.4.0.
  • Loading branch information
MikeMcQuaid committed Sep 24, 2024
1 parent bd3c7f8 commit 5eb3e0e
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 122 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def caveats(*strings, &block)
end

def discontinued?
odeprecated "`discontinued?`", "`deprecated?` or `disabled?`"
odisabled "`discontinued?`", "`deprecated?` or `disabled?`"
@caveats&.discontinued? == true
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/caveats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def eval_caveats(&block)
end

caveat :discontinued do
odeprecated "`caveats :discontinued`", "`deprecate!`"
odisabled "`caveats :discontinued`", "`deprecate!`"
@discontinued = true
<<~EOS
#{@cask} has been officially discontinued upstream.
Expand Down
10 changes: 5 additions & 5 deletions Library/Homebrew/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ def initialize(cmd = nil, &block)
@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),
T::Boolean)
# odeprecated(
# "`brew #{@command_name}'. This command needs to be refactored, as it is written in a style that",
# "inheritance from `Homebrew::AbstractCommand' ( see https://docs.brew.sh/External-Commands )",
# disable_for_developers: false,
# )
odeprecated(
"`brew #{@command_name}'. This command needs to be refactored, as it is written in a style that",
"inherits from `Homebrew::AbstractCommand' ( see https://docs.brew.sh/External-Commands )",
disable_for_developers: false,
)
end

@constraints = T.let([], T::Array[[String, String]])
Expand Down
7 changes: 0 additions & 7 deletions Library/Homebrew/cmd/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ class UpgradeCmd < AbstractCommand
"formula is outdated. Otherwise, the repository's HEAD will only be checked for " \
"updates when a new stable or development version has been released.",
}],
[:switch, "--ignore-pinned", {
description: "Set a successful exit status even if pinned formulae are not upgraded.",
hidden: true,
}],
[:switch, "--keep-tmp", {
description: "Retain the temporary files created during installation.",
}],
Expand Down Expand Up @@ -124,9 +120,6 @@ class UpgradeCmd < AbstractCommand

sig { override.void }
def run
# Disabled since this is now the default behavior.
odisabled "`brew upgrade --ignore-pinned`" if args.ignore_pinned?

formulae, casks = args.named.to_resolved_formulae_to_casks
# If one or more formulae are specified, but no casks were
# specified, we want to make note of that so we don't
Expand Down
4 changes: 0 additions & 4 deletions Library/Homebrew/dev-cmd/bump-cask-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class BumpCaskPr < AbstractCommand
"to the cask file."
switch "--no-audit",
description: "Don't run `brew audit` before opening the PR."
switch "--online",
hidden: true
switch "--no-style",
description: "Don't run `brew style --fix` before opening the PR."
switch "--no-browse",
Expand Down Expand Up @@ -60,8 +58,6 @@ class BumpCaskPr < AbstractCommand

sig { override.void }
def run
odisabled "brew bump-cask-pr --online" if args.online?

# This will be run by `brew audit` or `brew style` later so run it first to
# not start spamming during normal output.
gem_groups = []
Expand Down
4 changes: 0 additions & 4 deletions Library/Homebrew/dev-cmd/bump-formula-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,6 @@ def check_throttle(formula, new_version)
return if tap.nil?

throttled_rate = formula.livecheck.throttle
throttled_rate ||= if (rate = tap.audit_exceptions.dig(:throttled_formulae, formula.name))
odisabled "throttled_formulae.json", "Livecheck#throttle"
rate
end
return if throttled_rate.blank?

formula_suffix = Version.new(new_version).patch.to_i
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/dev-cmd/prof.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def run
Homebrew.setup_gem_environment!

if args.stackprof?
# odeprecated. vernier is better in every way
with_env HOMEBREW_STACKPROF: "1" do
system(*HOMEBREW_RUBY_EXEC_ARGS, brew_rb, *args.named)
end
Expand Down
7 changes: 0 additions & 7 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ def quiet!
@quiet = true
end

# Disable any output during downloading.
sig { void }
def shutup!
odisabled "`AbstractDownloadStrategy#shutup!`", "`AbstractDownloadStrategy#quiet!`"
quiet!
end

def quiet?
Context.current.quiet? || @quiet
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def rmtree(noop: nil, verbose: nil, secure: nil)
# create a RuboCop autocorrect instead soon.
# This is why monkeypatching is non-ideal (but right solution to get
# Ruby 3.3 over the line).
# odeprecated "rmtree", "FileUtils#rm_r"
odeprecated "rmtree", "FileUtils#rm_r"
FileUtils.rm_r(@path, noop:, verbose:, secure:)
nil
end
Expand Down
12 changes: 6 additions & 6 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ def with_logging(log_type)
#
# @see https://www.unix.com/man-page/all/5/plist/ <code>plist(5)</code> man page
def plist
odeprecated "`Formula#plist`", "`Homebrew::Service`"
odisabled "`Formula#plist`", "`Homebrew::Service`"
nil
end

Expand Down Expand Up @@ -2777,12 +2777,12 @@ def on_system_blocks_exist?
).returns(Pathname)
}
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
# odeprecated "Formula#fetch", "Resource#fetch on Formula#resource"
odeprecated "Formula#fetch", "Resource#fetch on Formula#resource"
active_spec.fetch(verify_download_integrity:, timeout:, quiet:)
end

def verify_download_integrity(filename)
# odeprecated "Formula#verify_download_integrity", "Resource#verify_download_integrity on Formula#resource"
odeprecated "Formula#verify_download_integrity", "Resource#verify_download_integrity on Formula#resource"
active_spec.verify_download_integrity(filename)
end

Expand Down Expand Up @@ -2887,8 +2887,8 @@ def install; end
def inreplace(paths, before = nil, after = nil, old_audit_result = nil, audit_result: 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?
# odeprecated "inreplace(paths, before, after, #{old_audit_result})",
# "inreplace(paths, before, after, audit_result: #{old_audit_result})"
odeprecated "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:, &block)
Expand Down Expand Up @@ -3749,7 +3749,7 @@ def resource(name, klass = Resource, &block)
#
# @api public
def go_resource(name, &block)
odeprecated "`Formula.go_resource`", "Go modules"
odisabled "`Formula.go_resource`", "Go modules"
specs.each { |spec| spec.go_resource(name, &block) }
end

Expand Down
9 changes: 7 additions & 2 deletions Library/Homebrew/git_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ def initialize(pathname)
def git_repository?
pathname.join(".git").exist?
end
# odeprecated: use git_repository? instead
alias git_repo? git_repository?

sig { returns(T::Boolean) }
def git_repo?
# delete this whole function when removing odisabled
odeprecated "GitRepository#git_repo?", "GitRepository#git_repository?"
git_repository?
end

# Gets the URL of the Git origin remote.
sig { returns(T.nilable(String)) }
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/github_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ def self.image_formula_name(formula_name)
end

def self.image_version_rebuild(version_rebuild)
return version_rebuild if version_rebuild.match?(VALID_OCI_TAG_REGEX)
unless version_rebuild.match?(VALID_OCI_TAG_REGEX)
raise ArgumentError, "GitHub Packages versions must match #{VALID_OCI_TAG_REGEX.source}!"
end

odisabled "GitHub Packages versions that do not match #{VALID_OCI_TAG_REGEX.source}",
"declaring a new `version` without these characters"
version_rebuild.gsub(INVALID_OCI_TAG_CHARS_REGEX, ".")
version_rebuild
end

private
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/language/go.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Go
# e.g. `resource "github.com/foo/bar"`.
sig { params(resources: T::Array[Resource], target: T.any(String, Pathname)).void }
def self.stage_deps(resources, target)
odeprecated "`Language::Go.stage_deps`", "Go modules"
odisabled "`Language::Go.stage_deps`", "Go modules"
if resources.empty?
if Homebrew::EnvConfig.developer?
odie "Tried to stage empty Language::Go resources array"
Expand Down
59 changes: 0 additions & 59 deletions Library/Homebrew/os/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,65 +56,6 @@ module Mac
::MacOS = OS::Mac

raise "Loaded OS::Linux on generic OS!" if ENV["HOMEBREW_TEST_GENERIC_OS"]

def self.version
odisabled "`MacOS.version` on Linux"
MacOSVersion::NULL
end

def self.full_version
odisabled "`MacOS.full_version` on Linux"
MacOSVersion::NULL
end

def self.languages
odisabled "`MacOS.languages` on Linux"
@languages ||= Array(ENV["LANG"]&.slice(/[a-z]+/)).uniq
end

def self.language
odisabled "`MacOS.language` on Linux"
languages.first
end

def self.sdk_root_needed?
odisabled "`MacOS.sdk_root_needed?` on Linux"
false
end

def self.sdk_path_if_needed(_version = nil)
odisabled "`MacOS.sdk_path_if_needed` on Linux"
nil
end

def self.sdk_path(_version = nil)
odisabled "`MacOS.sdk_path` on Linux"
nil
end

module Xcode
def self.version
odisabled "`MacOS::Xcode.version` on Linux"
::Version::NULL
end

def self.installed?
odisabled "`MacOS::Xcode.installed?` on Linux"
false
end
end

module CLT
def self.version
odisabled "`MacOS::CLT.version` on Linux"
::Version::NULL
end

def self.installed?
odisabled "`MacOS::CLT.installed?` on Linux"
false
end
end
end
# rubocop:enable Style/Documentation
end
12 changes: 6 additions & 6 deletions Library/Homebrew/os/mac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def self.version
# @api internal
sig { returns(MacOSVersion) }
def self.full_version
odisabled "`MacOS.full_version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS.full_version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
@full_version ||= if (fake_macos = ENV.fetch("HOMEBREW_FAKE_MACOS", nil)) # for Portable Ruby building
MacOSVersion.new(fake_macos)
else
Expand Down Expand Up @@ -68,7 +68,7 @@ def self.preferred_perl_version
end

def self.languages
odisabled "`MacOS.languages` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS.languages` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
return @languages if @languages

os_langs = Utils.popen_read("defaults", "read", "-g", "AppleLanguages")
Expand All @@ -82,7 +82,7 @@ def self.languages
end

def self.language
odisabled "`MacOS.language` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS.language` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
languages.first
end

Expand All @@ -93,7 +93,7 @@ def self.active_developer_dir

sig { returns(T::Boolean) }
def self.sdk_root_needed?
odisabled "`MacOS.sdk_root_needed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS.sdk_root_needed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
if MacOS::CLT.installed?
# If there's no CLT SDK, return false
return false unless MacOS::CLT.provides_sdk?
Expand Down Expand Up @@ -142,13 +142,13 @@ def self.sdk_for_formula(formula, version = nil, check_only_runtime_requirements

# Returns the path to an SDK or nil, following the rules set by {sdk}.
def self.sdk_path(version = nil)
odisabled "`MacOS.sdk_path` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS.sdk_path` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
s = sdk(version)
s&.path
end

def self.sdk_path_if_needed(version = nil)
odisabled "`MacOS.sdk_path_if_needed` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS.sdk_path_if_needed` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
# Prefer CLT SDK when both Xcode and the CLT are installed.
# Expected results:
# 1. On Xcode-only systems, return the Xcode SDK.
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/os/mac/xcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def self.bundle_path

sig { returns(T::Boolean) }
def self.installed?
odisabled "`MacOS::Xcode.installed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS::Xcode.installed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
!prefix.nil?
end

Expand Down Expand Up @@ -178,7 +178,7 @@ def self.update_instructions
# @api internal
sig { returns(::Version) }
def self.version
odisabled "`MacOS::Xcode.version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS::Xcode.version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
# may return a version string
# that is guessed based on the compiler, so do not
# use it in order to check if Xcode is installed.
Expand Down Expand Up @@ -278,7 +278,7 @@ module CLT
# Returns true even if outdated tools are installed.
sig { returns(T::Boolean) }
def self.installed?
odisabled "`MacOS::CLT.installed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS::CLT.installed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
!version.null?
end

Expand Down Expand Up @@ -423,7 +423,7 @@ def self.detect_version_from_clang_version
# @api internal
sig { returns(::Version) }
def self.version
odisabled "`MacOS::CLT.version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
raise "`MacOS::CLT.version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
if @version ||= detect_version
::Version.new @version
else
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/software_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def resource(name = T.unsafe(nil), klass = Resource, &block)
end

def go_resource(name, &block)
odeprecated "`SoftwareSpec#go_resource`", "Go modules"
odisabled "`SoftwareSpec#go_resource`", "Go modules"
resource name, Resource::Go, &block
end

Expand Down
Loading

0 comments on commit 5eb3e0e

Please sign in to comment.