Skip to content

Commit

Permalink
Merge pull request #16352 from Rylan12/fix-cask-discontinued-api-gene…
Browse files Browse the repository at this point in the history
…ration

Re-add some `discontinued?` checks for casks
  • Loading branch information
Bo98 committed Dec 18, 2023
2 parents fe74f59 + 25b753f commit b72421e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def audit_latest_with_auto_updates

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?
Expand Down Expand Up @@ -683,7 +683,7 @@ def audit_gitlab_prerelease_version
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?
Expand All @@ -697,7 +697,7 @@ def audit_github_repository_archived
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?
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/cask/cask.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module Cask

def desc; end

def discontinued?; end

def deprecated?; end

def deprecation_date; end
Expand Down
9 changes: 2 additions & 7 deletions Library/Homebrew/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DSL
:disabled?,
:disable_date,
:disable_reason,
:discontinued?,
:discontinued?, # TODO: remove once discontinued? is removed (4.5.0)
:livecheck,
:livecheckable?,
:on_system_blocks_exist?,
Expand All @@ -106,7 +106,7 @@ class DSL

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
Expand Down Expand Up @@ -328,11 +328,6 @@ def discontinued?
@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 }
Expand Down
15 changes: 15 additions & 0 deletions Library/Homebrew/livecheck/skip_conditions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ def formula_versioned(formula, livecheckable, full_name: false, verbose: false)
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,
Expand Down Expand Up @@ -179,6 +193,7 @@ def cask_url_unversioned(cask, livecheckable, full_name: false, verbose: false)
# Skip conditions for casks.
CASK_CHECKS = [
:package_or_resource_skip,
:cask_discontinued,
:cask_deprecated,
:cask_disabled,
:cask_version_latest,
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/livecheck/skip_conditions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
cask: {
discontinued: {
cask: "test_discontinued",
status: "deprecated",
status: "discontinued",
meta: {
livecheckable: false,
},
Expand Down Expand Up @@ -478,7 +478,7 @@
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

Expand Down Expand Up @@ -601,7 +601,7 @@
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
Expand Down

0 comments on commit b72421e

Please sign in to comment.