diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index be8f44aeae..b64cf9704d 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -289,7 +289,7 @@ module Cask sig { params(livecheck_result: T.any(NilClass, T::Boolean, Symbol)).void } def audit_hosting_with_livecheck(livecheck_result: audit_livecheck_version) - return if cask.deprecated? || cask.disabled? + return if cask.discontinued? || cask.deprecated? || cask.disabled? return if cask.version&.latest? return unless cask.url return if block_url_offline? @@ -683,7 +683,7 @@ module Cask sig { void } def audit_github_repository_archived # Deprecated/disabled casks may have an archived repo. - return if cask.deprecated? || cask.disabled? + return if cask.discontinued? || cask.deprecated? || cask.disabled? user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online? return if user.nil? @@ -697,7 +697,7 @@ module Cask sig { void } def audit_gitlab_repository_archived # Deprecated/disabled casks may have an archived repo. - return if cask.deprecated? || cask.disabled? + return if cask.discontinued? || cask.deprecated? || cask.disabled? user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online? return if user.nil? diff --git a/Library/Homebrew/cask/cask.rbi b/Library/Homebrew/cask/cask.rbi index 2a7d80d53d..40fbb7a6a1 100644 --- a/Library/Homebrew/cask/cask.rbi +++ b/Library/Homebrew/cask/cask.rbi @@ -20,6 +20,8 @@ module Cask def desc; end + def discontinued?; end + def deprecated?; end def deprecation_date; end diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index 1a08657cef..e6c31b8ec3 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -92,7 +92,7 @@ module Cask :disabled?, :disable_date, :disable_reason, - :discontinued?, + :discontinued?, # TODO: remove once discontinued? is removed (4.5.0) :livecheck, :livecheckable?, :on_system_blocks_exist?, @@ -106,7 +106,7 @@ module Cask attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :disable_date, :disable_reason - attr_predicate :on_system_blocks_exist?, :disabled?, :livecheckable? + attr_predicate :on_system_blocks_exist?, :deprecated?, :disabled?, :livecheckable? def initialize(cask) @cask = cask @@ -328,11 +328,6 @@ module Cask @caveats&.discontinued? == true end - # TODO: replace with with attr_predicate once discontinued? is disabled - def deprecated? - @deprecated == true || @caveats&.discontinued? == true - end - # @api public def auto_updates(auto_updates = nil) set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates } diff --git a/Library/Homebrew/livecheck/skip_conditions.rb b/Library/Homebrew/livecheck/skip_conditions.rb index d6401fa704..9b34e7f6d7 100644 --- a/Library/Homebrew/livecheck/skip_conditions.rb +++ b/Library/Homebrew/livecheck/skip_conditions.rb @@ -111,6 +111,20 @@ module Homebrew Livecheck.status_hash(formula, "versioned", full_name: full_name, verbose: verbose) end + sig { + params( + cask: Cask::Cask, + livecheckable: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, + ).returns(Hash) + } + def cask_discontinued(cask, livecheckable, full_name: false, verbose: false) + return {} if !cask.discontinued? || livecheckable + + Livecheck.status_hash(cask, "discontinued", full_name: full_name, verbose: verbose) + end + sig { params( cask: Cask::Cask, @@ -179,6 +193,7 @@ module Homebrew # Skip conditions for casks. CASK_CHECKS = [ :package_or_resource_skip, + :cask_discontinued, :cask_deprecated, :cask_disabled, :cask_version_latest, diff --git a/Library/Homebrew/test/livecheck/skip_conditions_spec.rb b/Library/Homebrew/test/livecheck/skip_conditions_spec.rb index ba6840923b..4d3e9d9eab 100644 --- a/Library/Homebrew/test/livecheck/skip_conditions_spec.rb +++ b/Library/Homebrew/test/livecheck/skip_conditions_spec.rb @@ -247,7 +247,7 @@ describe Homebrew::Livecheck::SkipConditions do cask: { discontinued: { cask: "test_discontinued", - status: "deprecated", + status: "discontinued", meta: { livecheckable: false, }, @@ -478,7 +478,7 @@ describe Homebrew::Livecheck::SkipConditions do context "when a cask without a livecheckable is discontinued" do it "errors" do expect { skip_conditions.referenced_skip_information(casks[:discontinued], original_name) } - .to raise_error(RuntimeError, "Referenced cask (test_discontinued) is skipped as deprecated") + .to raise_error(RuntimeError, "Referenced cask (test_discontinued) is skipped as discontinued") end end @@ -601,7 +601,7 @@ describe Homebrew::Livecheck::SkipConditions do context "when the cask is discontinued without a livecheckable" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:cask][:discontinued]) } - .to output("test_discontinued: deprecated\n").to_stdout + .to output("test_discontinued: discontinued\n").to_stdout .and not_to_output.to_stderr end end