Merge pull request #16292 from Rylan12/cask-deprecate-disable

Add `deprecate!` and `disable!` to casks
This commit is contained in:
Rylan Polster 2023-12-17 15:03:39 -05:00 committed by GitHub
commit 4793677123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 369 additions and 78 deletions

View File

@ -289,7 +289,7 @@ module Cask
sig { params(livecheck_result: T.any(NilClass, T::Boolean, Symbol)).void } sig { params(livecheck_result: T.any(NilClass, T::Boolean, Symbol)).void }
def audit_hosting_with_livecheck(livecheck_result: audit_livecheck_version) def audit_hosting_with_livecheck(livecheck_result: audit_livecheck_version)
return if cask.discontinued? return if cask.deprecated? || cask.disabled?
return if cask.version&.latest? return if cask.version&.latest?
return unless cask.url return unless cask.url
return if block_url_offline? return if block_url_offline?
@ -544,7 +544,7 @@ module Cask
) )
end end
# Respect cask skip conditions (e.g. discontinued, latest, unversioned) # Respect cask skip conditions (e.g. deprecated, disabled, latest, unversioned)
skip_info ||= Homebrew::Livecheck::SkipConditions.skip_information(cask) skip_info ||= Homebrew::Livecheck::SkipConditions.skip_information(cask)
return :skip if skip_info.present? return :skip if skip_info.present?
@ -682,8 +682,8 @@ module Cask
sig { void } sig { void }
def audit_github_repository_archived def audit_github_repository_archived
# Discontinued casks may have an archived repo. # Deprecated/disabled casks may have an archived repo.
return if cask.discontinued? return if cask.deprecated? || cask.disabled?
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online? user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online?
return if user.nil? return if user.nil?
@ -696,8 +696,8 @@ module Cask
sig { void } sig { void }
def audit_gitlab_repository_archived def audit_gitlab_repository_archived
# Discontinued casks may have an archived repo. # Deprecated/disabled casks may have an archived repo.
return if cask.discontinued? return if cask.deprecated? || cask.disabled?
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online? user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online?
return if user.nil? return if user.nil?

View File

@ -331,6 +331,12 @@ module Cask
"conflicts_with" => conflicts_with, "conflicts_with" => conflicts_with,
"container" => container&.pairs, "container" => container&.pairs,
"auto_updates" => auto_updates, "auto_updates" => auto_updates,
"deprecated" => deprecated?,
"deprecation_date" => deprecation_date,
"deprecation_reason" => deprecation_reason,
"disabled" => disabled?,
"disable_date" => disable_date,
"disable_reason" => disable_reason,
"tap_git_head" => tap_git_head, "tap_git_head" => tap_git_head,
"languages" => languages, "languages" => languages,
"ruby_source_path" => ruby_source_path, "ruby_source_path" => ruby_source_path,

View File

@ -20,7 +20,17 @@ module Cask
def desc; end def desc; end
def discontinued?; end def deprecated?; end
def deprecation_date; end
def deprecation_reason; end
def disabled?; end
def disable_date; end
def disable_reason; end
def homepage; end def homepage; end

View File

@ -286,6 +286,16 @@ module Cask
desc json_cask[:desc] desc json_cask[:desc]
homepage json_cask[:homepage] homepage json_cask[:homepage]
if (deprecation_date = json_cask[:deprecation_date].presence)
reason = DeprecateDisable.to_reason_string_or_symbol json_cask[:deprecation_reason], type: :cask
deprecate! date: deprecation_date, because: reason
end
if (disable_date = json_cask[:disable_date].presence)
reason = DeprecateDisable.to_reason_string_or_symbol json_cask[:disable_reason], type: :cask
disable! date: disable_date, because: reason
end
auto_updates json_cask[:auto_updates] unless json_cask[:auto_updates].nil? auto_updates json_cask[:auto_updates] unless json_cask[:auto_updates].nil?
conflicts_with(**json_cask[:conflicts_with]) if json_cask[:conflicts_with].present? conflicts_with(**json_cask[:conflicts_with]) if json_cask[:conflicts_with].present?

View File

@ -84,6 +84,14 @@ module Cask
:url, :url,
:version, :version,
:appdir, :appdir,
:deprecate!,
:deprecated?,
:deprecation_date,
:deprecation_reason,
:disable!,
:disabled?,
:disable_date,
:disable_reason,
:discontinued?, :discontinued?,
:livecheck, :livecheck,
:livecheckable?, :livecheckable?,
@ -96,9 +104,9 @@ module Cask
extend Predicable extend Predicable
include OnSystem::MacOSOnly include OnSystem::MacOSOnly
attr_reader :cask, :token attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :disable_date, :disable_reason
attr_predicate :on_system_blocks_exist? attr_predicate :on_system_blocks_exist?, :disabled?, :livecheckable?
def initialize(cask) def initialize(cask)
@cask = cask @cask = cask
@ -316,9 +324,15 @@ module Cask
end end
def discontinued? def discontinued?
# odeprecated "`discontinued?`", "`deprecated?` or `disabled?`"
@caveats&.discontinued? == true @caveats&.discontinued? == true
end end
# TODO: replace with with attr_predicate once discontinued? is disabled
def deprecated?
@deprecated == true || @caveats&.discontinued? == true
end
# @api public # @api public
def auto_updates(auto_updates = nil) def auto_updates(auto_updates = nil)
set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates } set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates }
@ -337,8 +351,27 @@ module Cask
@livecheck.instance_eval(&block) @livecheck.instance_eval(&block)
end end
def livecheckable? # @api public
@livecheckable == true def deprecate!(date:, because:)
@deprecation_date = Date.parse(date)
return if @deprecation_date > Date.today
@deprecation_reason = because
@deprecated = true
end
# @api public
def disable!(date:, because:)
@disable_date = Date.parse(date)
if @disable_date > Date.today
@deprecation_reason = because
@deprecated = true
return
end
@disable_reason = because
@disabled = true
end end
ORDINARY_ARTIFACT_CLASSES.each do |klass| ORDINARY_ARTIFACT_CLASSES.each do |klass|

View File

@ -163,6 +163,7 @@ module Cask
end end
caveat :discontinued do caveat :discontinued do
# odeprecated "`caveats :discontinued`", "`deprecate!`"
@discontinued = true @discontinued = true
<<~EOS <<~EOS
#{@cask} has been officially discontinued upstream. #{@cask} has been officially discontinued upstream.

View File

@ -54,6 +54,23 @@ module Cask
end end
end end
# Error when a cask cannot be installed.
#
# @api private
class CaskCannotBeInstalledError < AbstractCaskErrorWithToken
attr_reader :message
def initialize(token, message)
super(token)
@message = message
end
sig { returns(String) }
def to_s
"Cask '#{token}' has been #{message}"
end
end
# Error when a cask conflicts with another cask. # Error when a cask conflicts with another cask.
# #
# @api private # @api private

View File

@ -12,6 +12,8 @@ module Cask
output = +"#{title_info(cask)}\n" output = +"#{title_info(cask)}\n"
output << "#{Formatter.url(cask.homepage)}\n" if cask.homepage output << "#{Formatter.url(cask.homepage)}\n" if cask.homepage
deprecate_disable = DeprecateDisable.message(cask)
output << "#{deprecate_disable.capitalize}\n" if deprecate_disable
output << installation_info(cask) output << installation_info(cask)
repo = repo_info(cask) repo = repo_info(cask)
output << "#{repo}\n" if repo output << "#{repo}\n" if repo

View File

@ -93,6 +93,7 @@ module Cask
old_config = @cask.config old_config = @cask.config
predecessor = @cask if reinstall? && @cask.installed? predecessor = @cask if reinstall? && @cask.installed?
check_deprecate_disable
check_conflicts check_conflicts
print caveats print caveats
@ -124,6 +125,18 @@ on_request: true)
raise raise
end end
def check_deprecate_disable
deprecate_disable_type = DeprecateDisable.type(@cask)
return if deprecate_disable_type.nil?
case deprecate_disable_type
when :deprecated
opoo "#{@cask.token} has been #{DeprecateDisable.message(@cask)}"
when :disabled
raise CaskCannotBeInstalledError.new(@cask, DeprecateDisable.message(@cask))
end
end
def check_conflicts def check_conflicts
return unless @cask.conflicts_with return unless @cask.conflicts_with

View File

@ -278,14 +278,8 @@ module Homebrew
puts formula.desc if formula.desc puts formula.desc if formula.desc
puts Formatter.url(formula.homepage) if formula.homepage puts Formatter.url(formula.homepage) if formula.homepage
deprecate_disable_type, deprecate_disable_reason = DeprecateDisable.deprecate_disable_info formula deprecate_disable_info_string = DeprecateDisable.message(formula)
if deprecate_disable_type.present? puts deprecate_disable_info_string.capitalize if deprecate_disable_info_string.present?
if deprecate_disable_reason.present?
puts "#{deprecate_disable_type.capitalize} because it #{deprecate_disable_reason}!"
else
puts "#{deprecate_disable_type.capitalize}!"
end
end
conflicts = formula.conflicts.map do |conflict| conflicts = formula.conflicts.map do |conflict|
reason = " (because #{conflict.reason})" if conflict.reason reason = " (because #{conflict.reason})" if conflict.reason

View File

@ -7,7 +7,7 @@
module DeprecateDisable module DeprecateDisable
module_function module_function
DEPRECATE_DISABLE_REASONS = { FORMULA_DEPRECATE_DISABLE_REASONS = {
does_not_build: "does not build", does_not_build: "does not build",
no_license: "has no license", no_license: "has no license",
repo_archived: "has an archived upstream repository", repo_archived: "has an archived upstream repository",
@ -22,19 +22,44 @@ module DeprecateDisable
"We can re-package this once upstream has confirmed that they retagged their release", "We can re-package this once upstream has confirmed that they retagged their release",
}.freeze }.freeze
def deprecate_disable_info(formula) CASK_DEPRECATE_DISABLE_REASONS = {
if formula.deprecated? discontinued: "is discontinued upstream",
type = :deprecated }.freeze
reason = formula.deprecation_reason
elsif formula.disabled? def type(formula_or_cask)
type = :disabled return :deprecated if formula_or_cask.deprecated?
reason = formula.disable_reason
else :disabled if formula_or_cask.disabled?
return end
def message(formula_or_cask)
return if type(formula_or_cask).blank?
reason = if formula_or_cask.deprecated?
formula_or_cask.deprecation_reason
elsif formula_or_cask.disabled?
formula_or_cask.disable_reason
end end
reason = DEPRECATE_DISABLE_REASONS[reason] if DEPRECATE_DISABLE_REASONS.key? reason reason = if formula_or_cask.is_a?(Formula) && FORMULA_DEPRECATE_DISABLE_REASONS.key?(reason)
FORMULA_DEPRECATE_DISABLE_REASONS[reason]
elsif formula_or_cask.is_a?(Cask::Cask) && CASK_DEPRECATE_DISABLE_REASONS.key?(reason)
CASK_DEPRECATE_DISABLE_REASONS[reason]
else
reason
end
[type, reason] return "#{type(formula_or_cask)} because it #{reason}!" if reason.present?
"#{type(formula_or_cask)}!"
end
def to_reason_string_or_symbol(string, type:)
if (type == :formula && FORMULA_DEPRECATE_DISABLE_REASONS.key?(string&.to_sym)) ||
(type == :cask && CASK_DEPRECATE_DISABLE_REASONS.key?(string&.to_sym))
return string.to_sym
end
string
end end
end end

View File

@ -642,6 +642,18 @@ module Homebrew
EOS EOS
end end
def check_cask_deprecated_disabled
deprecated_or_disabled = Cask::Caskroom.casks.select(&:deprecated?)
deprecated_or_disabled += Cask::Caskroom.casks.select(&:disabled?)
return if deprecated_or_disabled.empty?
<<~EOS
Some installed casks are deprecated or disabled.
You should find replacements for the following casks:
#{deprecated_or_disabled.sort_by(&:token).uniq * "\n "}
EOS
end
sig { returns(T.nilable(String)) } sig { returns(T.nilable(String)) }
def check_git_status def check_git_status
return unless Utils::Git.available? return unless Utils::Git.available?

View File

@ -3550,7 +3550,7 @@ class Formula
# <pre>deprecate! date: "2020-08-27", because: :unmaintained</pre> # <pre>deprecate! date: "2020-08-27", because: :unmaintained</pre>
# <pre>deprecate! date: "2020-08-27", because: "has been replaced by foo"</pre> # <pre>deprecate! date: "2020-08-27", because: "has been replaced by foo"</pre>
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae # @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
# @see DeprecateDisable::DEPRECATE_DISABLE_REASONS # @see DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS
def deprecate!(date:, because:) def deprecate!(date:, because:)
@deprecation_date = Date.parse(date) @deprecation_date = Date.parse(date)
return if @deprecation_date > Date.today return if @deprecation_date > Date.today
@ -3585,7 +3585,7 @@ class Formula
# <pre>disable! date: "2020-08-27", because: :does_not_build</pre> # <pre>disable! date: "2020-08-27", because: :does_not_build</pre>
# <pre>disable! date: "2020-08-27", because: "has been replaced by foo"</pre> # <pre>disable! date: "2020-08-27", because: "has been replaced by foo"</pre>
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae # @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
# @see DeprecateDisable::DEPRECATE_DISABLE_REASONS # @see DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS
def disable!(date:, because:) def disable!(date:, because:)
@disable_date = Date.parse(date) @disable_date = Date.parse(date)

View File

@ -412,7 +412,7 @@ module Homebrew
return if formula.disabled? return if formula.disabled?
return if formula.deprecated? && return if formula.deprecated? &&
formula.deprecation_reason != DeprecateDisable::DEPRECATE_DISABLE_REASONS[:versioned_formula] formula.deprecation_reason != DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS[:versioned_formula]
problem <<~EOS problem <<~EOS
#{formula.full_name} contains conflicting version recursive dependencies: #{formula.full_name} contains conflicting version recursive dependencies:

View File

@ -200,21 +200,15 @@ class FormulaInstaller
sig { void } sig { void }
def prelude def prelude
type, reason = DeprecateDisable.deprecate_disable_info formula deprecate_disable_type = DeprecateDisable.type(formula)
if type.present? if deprecate_disable_type.present?
case type message = "#{formula.full_name} has been #{DeprecateDisable.message(formula)}"
when :deprecated
if reason.present?
opoo "#{formula.full_name} has been deprecated because it #{reason}!"
else
opoo "#{formula.full_name} has been deprecated!"
end
when :disabled
if reason.present?
raise CannotInstallFormulaError, "#{formula.full_name} has been disabled because it #{reason}!"
end
raise CannotInstallFormulaError, "#{formula.full_name} has been disabled!" case deprecate_disable_type
when :deprecated
opoo message
when :disabled
raise CannotInstallFormulaError, message
end end
end end

View File

@ -7,6 +7,7 @@ require "tab"
require "utils/bottles" require "utils/bottles"
require "service" require "service"
require "utils/curl" require "utils/curl"
require "deprecate_disable"
require "active_support/core_ext/hash/deep_transform_values" require "active_support/core_ext/hash/deep_transform_values"
@ -301,12 +302,12 @@ module Formulary
end end
if (deprecation_date = json_formula["deprecation_date"].presence) if (deprecation_date = json_formula["deprecation_date"].presence)
reason = Formulary.convert_to_deprecate_disable_reason_string_or_symbol json_formula["deprecation_reason"] reason = DeprecateDisable.to_reason_string_or_symbol json_formula["deprecation_reason"], type: :formula
deprecate! date: deprecation_date, because: reason deprecate! date: deprecation_date, because: reason
end end
if (disable_date = json_formula["disable_date"].presence) if (disable_date = json_formula["disable_date"].presence)
reason = Formulary.convert_to_deprecate_disable_reason_string_or_symbol json_formula["disable_reason"] reason = DeprecateDisable.to_reason_string_or_symbol json_formula["disable_reason"], type: :formula
disable! date: disable_date, because: reason disable! date: disable_date, because: reason
end end
@ -462,13 +463,6 @@ module Formulary
string string
end end
def self.convert_to_deprecate_disable_reason_string_or_symbol(string)
require "deprecate_disable"
return string unless DeprecateDisable::DEPRECATE_DISABLE_REASONS.keys.map(&:to_s).include?(string)
string.to_sym
end
# A {FormulaLoader} returns instances of formulae. # A {FormulaLoader} returns instances of formulae.
# Subclasses implement loaders for particular sources of formulae. # Subclasses implement loaders for particular sources of formulae.
class FormulaLoader class FormulaLoader

View File

@ -119,10 +119,24 @@ module Homebrew
verbose: T::Boolean, verbose: T::Boolean,
).returns(Hash) ).returns(Hash)
} }
def cask_discontinued(cask, livecheckable, full_name: false, verbose: false) def cask_deprecated(cask, livecheckable, full_name: false, verbose: false)
return {} if !cask.discontinued? || livecheckable return {} if !cask.deprecated? || livecheckable
Livecheck.status_hash(cask, "discontinued", full_name: full_name, verbose: verbose) Livecheck.status_hash(cask, "deprecated", 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_disabled(cask, livecheckable, full_name: false, verbose: false)
return {} if !cask.disabled? || livecheckable
Livecheck.status_hash(cask, "disabled", full_name: full_name, verbose: verbose)
end end
sig { sig {
@ -165,7 +179,8 @@ module Homebrew
# Skip conditions for casks. # Skip conditions for casks.
CASK_CHECKS = [ CASK_CHECKS = [
:package_or_resource_skip, :package_or_resource_skip,
:cask_discontinued, :cask_deprecated,
:cask_disabled,
:cask_version_latest, :cask_version_latest,
:cask_url_unversioned, :cask_url_unversioned,
].freeze ].freeze

View File

@ -74,9 +74,9 @@ module RuboCop
Constants::STANZA_ORDER.each do |stanza_name| Constants::STANZA_ORDER.each do |stanza_name|
class_eval <<-RUBY, __FILE__, __LINE__ + 1 class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{stanza_name}? # def url? def #{stanza_name.to_s.chomp("!")}? # def url?
stanza_name == :#{stanza_name} # stanza_name == :url stanza_name == :#{stanza_name} # stanza_name == :url
end # end end # end
RUBY RUBY
end end
end end

View File

@ -19,6 +19,7 @@ module RuboCop
[:language], [:language],
[:url, :appcast, :name, :desc, :homepage], [:url, :appcast, :name, :desc, :homepage],
[:livecheck], [:livecheck],
[:deprecate!, :disable!],
[ [
:auto_updates, :auto_updates,
:conflicts_with, :conflicts_with,

View File

@ -0,0 +1,89 @@
# frozen_string_literal: true
require "deprecate_disable"
describe DeprecateDisable do
let(:deprecated_formula) do
instance_double(Formula, deprecated?: true, disabled?: false, deprecation_reason: :does_not_build)
end
let(:disabled_formula) do
instance_double(Formula, deprecated?: false, disabled?: true, disable_reason: "is broken")
end
let(:deprecated_cask) do
instance_double(Cask::Cask, deprecated?: true, disabled?: false, deprecation_reason: :discontinued)
end
let(:disabled_cask) do
instance_double(Cask::Cask, deprecated?: false, disabled?: true, disable_reason: nil)
end
before do
allow(deprecated_formula).to receive(:is_a?).with(Formula).and_return(true)
allow(deprecated_formula).to receive(:is_a?).with(Cask::Cask).and_return(false)
allow(disabled_formula).to receive(:is_a?).with(Formula).and_return(true)
allow(disabled_formula).to receive(:is_a?).with(Cask::Cask).and_return(false)
allow(deprecated_cask).to receive(:is_a?).with(Formula).and_return(false)
allow(deprecated_cask).to receive(:is_a?).with(Cask::Cask).and_return(true)
allow(disabled_cask).to receive(:is_a?).with(Formula).and_return(false)
allow(disabled_cask).to receive(:is_a?).with(Cask::Cask).and_return(true)
end
describe "::type" do
it "returns :deprecated if the formula is deprecated" do
expect(described_class.type(deprecated_formula)).to eq :deprecated
end
it "returns :disabled if the formula is disabled" do
expect(described_class.type(disabled_formula)).to eq :disabled
end
it "returns :deprecated if the cask is deprecated" do
expect(described_class.type(deprecated_cask)).to eq :deprecated
end
it "returns :disabled if the cask is disabled" do
expect(described_class.type(disabled_cask)).to eq :disabled
end
end
describe "::message" do
it "returns a deprecation message with a preset formula reason" do
expect(described_class.message(deprecated_formula))
.to eq "deprecated because it does not build!"
end
it "returns a disable message with a custom reason" do
expect(described_class.message(disabled_formula))
.to eq "disabled because it is broken!"
end
it "returns a deprecation message with a preset cask reason" do
expect(described_class.message(deprecated_cask))
.to eq "deprecated because it is discontinued upstream!"
end
it "returns a deprecation message with no reason" do
expect(described_class.message(disabled_cask))
.to eq "disabled!"
end
end
describe "::to_reason_string_or_symbol" do
it "returns the original string if it isn't a formula preset reason" do
expect(described_class.to_reason_string_or_symbol("discontinued", type: :formula)).to eq "discontinued"
end
it "returns the original string if it isn't a cask preset reason" do
expect(described_class.to_reason_string_or_symbol("does_not_build", type: :cask)).to eq "does_not_build"
end
it "returns a symbol if the original string is a formula preset reason" do
expect(described_class.to_reason_string_or_symbol("does_not_build", type: :formula))
.to eq :does_not_build
end
it "returns a symbol if the original string is a cask preset reason" do
expect(described_class.to_reason_string_or_symbol("discontinued", type: :cask))
.to eq :discontinued
end
end
end

View File

@ -521,15 +521,4 @@ describe Formulary do
expect(described_class.convert_to_string_or_symbol(":foo")).to eq :foo expect(described_class.convert_to_string_or_symbol(":foo")).to eq :foo
end end
end end
describe "::convert_to_deprecate_disable_reason_string_or_symbol" do
it "returns the original string if it isn't a preset reason" do
expect(described_class.convert_to_deprecate_disable_reason_string_or_symbol("foo")).to eq "foo"
end
it "returns a symbol if the original string is a preset reason" do
expect(described_class.convert_to_deprecate_disable_reason_string_or_symbol("does_not_build"))
.to eq :does_not_build
end
end
end end

View File

@ -104,6 +104,28 @@ describe Homebrew::Livecheck::SkipConditions do
discontinued discontinued
end end
end, end,
deprecated: Cask::Cask.new("test_deprecated") do
version "0.0.1"
sha256 :no_check
url "https://brew.sh/test-0.0.1.tgz"
name "Test Deprecate"
desc "Deprecated test cask"
homepage "https://brew.sh"
deprecate! date: "2020-06-25", because: :discontinued
end,
disabled: Cask::Cask.new("test_disabled") do
version "0.0.1"
sha256 :no_check
url "https://brew.sh/test-0.0.1.tgz"
name "Test Disable"
desc "Disabled test cask"
homepage "https://brew.sh"
disable! date: "2020-06-25", because: :discontinued
end,
latest: Cask::Cask.new("test_latest") do latest: Cask::Cask.new("test_latest") do
version :latest version :latest
sha256 :no_check sha256 :no_check
@ -225,7 +247,21 @@ describe Homebrew::Livecheck::SkipConditions do
cask: { cask: {
discontinued: { discontinued: {
cask: "test_discontinued", cask: "test_discontinued",
status: "discontinued", status: "deprecated",
meta: {
livecheckable: false,
},
},
deprecated: {
cask: "test_deprecated",
status: "deprecated",
meta: {
livecheckable: false,
},
},
disabled: {
cask: "test_disabled",
status: "disabled",
meta: { meta: {
livecheckable: false, livecheckable: false,
}, },
@ -330,6 +366,20 @@ describe Homebrew::Livecheck::SkipConditions do
end end
end end
context "when a cask without a livecheckable is deprecated" do
it "skips" do
expect(skip_conditions.skip_information(casks[:deprecated]))
.to eq(status_hashes[:cask][:deprecated])
end
end
context "when a cask without a livecheckable is disabled" do
it "skips" do
expect(skip_conditions.skip_information(casks[:disabled]))
.to eq(status_hashes[:cask][:disabled])
end
end
context "when a cask without a livecheckable has `version :latest`" do context "when a cask without a livecheckable has `version :latest`" do
it "skips" do it "skips" do
expect(skip_conditions.skip_information(casks[:latest])) expect(skip_conditions.skip_information(casks[:latest]))
@ -428,7 +478,21 @@ describe Homebrew::Livecheck::SkipConditions do
context "when a cask without a livecheckable is discontinued" do context "when a cask without a livecheckable is discontinued" do
it "errors" do it "errors" do
expect { skip_conditions.referenced_skip_information(casks[:discontinued], original_name) } expect { skip_conditions.referenced_skip_information(casks[:discontinued], original_name) }
.to raise_error(RuntimeError, "Referenced cask (test_discontinued) is skipped as discontinued") .to raise_error(RuntimeError, "Referenced cask (test_discontinued) is skipped as deprecated")
end
end
context "when a cask without a livecheckable is deprecated" do
it "errors" do
expect { skip_conditions.referenced_skip_information(casks[:deprecated], original_name) }
.to raise_error(RuntimeError, "Referenced cask (test_deprecated) is skipped as deprecated")
end
end
context "when a cask without a livecheckable is disabled" do
it "errors" do
expect { skip_conditions.referenced_skip_information(casks[:disabled], original_name) }
.to raise_error(RuntimeError, "Referenced cask (test_disabled) is skipped as disabled")
end end
end end
@ -537,7 +601,23 @@ describe Homebrew::Livecheck::SkipConditions do
context "when the cask is discontinued without a livecheckable" do context "when the cask is discontinued without a livecheckable" do
it "prints skip information" do it "prints skip information" do
expect { skip_conditions.print_skip_information(status_hashes[:cask][:discontinued]) } expect { skip_conditions.print_skip_information(status_hashes[:cask][:discontinued]) }
.to output("test_discontinued: discontinued\n").to_stdout .to output("test_discontinued: deprecated\n").to_stdout
.and not_to_output.to_stderr
end
end
context "when the cask is deprecated without a livecheckable" do
it "prints skip information" do
expect { skip_conditions.print_skip_information(status_hashes[:cask][:deprecated]) }
.to output("test_deprecated: deprecated\n").to_stdout
.and not_to_output.to_stderr
end
end
context "when the cask is disabled without a livecheckable" do
it "prints skip information" do
expect { skip_conditions.print_skip_information(status_hashes[:cask][:disabled]) }
.to output("test_disabled: disabled\n").to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
end end
end end

View File

@ -90,6 +90,12 @@
"type": "naked" "type": "naked"
}, },
"auto_updates": true, "auto_updates": true,
"deprecated": false,
"deprecation_date": null,
"deprecation_reason": null,
"disabled": false,
"disable_date": null,
"disable_reason": null,
"tap_git_head": null, "tap_git_head": null,
"languages": [ "languages": [
"en", "en",