Merge pull request #16292 from Rylan12/cask-deprecate-disable
Add `deprecate!` and `disable!` to casks
This commit is contained in:
commit
4793677123
@ -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.discontinued?
|
||||
return if cask.deprecated? || cask.disabled?
|
||||
return if cask.version&.latest?
|
||||
return unless cask.url
|
||||
return if block_url_offline?
|
||||
@ -544,7 +544,7 @@ module Cask
|
||||
)
|
||||
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)
|
||||
return :skip if skip_info.present?
|
||||
|
||||
@ -682,8 +682,8 @@ module Cask
|
||||
|
||||
sig { void }
|
||||
def audit_github_repository_archived
|
||||
# Discontinued casks may have an archived repo.
|
||||
return if cask.discontinued?
|
||||
# Deprecated/disabled casks may have an archived repo.
|
||||
return if cask.deprecated? || cask.disabled?
|
||||
|
||||
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if online?
|
||||
return if user.nil?
|
||||
@ -696,8 +696,8 @@ module Cask
|
||||
|
||||
sig { void }
|
||||
def audit_gitlab_repository_archived
|
||||
# Discontinued casks may have an archived repo.
|
||||
return if cask.discontinued?
|
||||
# Deprecated/disabled casks may have an archived repo.
|
||||
return if cask.deprecated? || cask.disabled?
|
||||
|
||||
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if online?
|
||||
return if user.nil?
|
||||
|
||||
@ -331,6 +331,12 @@ module Cask
|
||||
"conflicts_with" => conflicts_with,
|
||||
"container" => container&.pairs,
|
||||
"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,
|
||||
"languages" => languages,
|
||||
"ruby_source_path" => ruby_source_path,
|
||||
|
||||
@ -20,7 +20,17 @@ module Cask
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -286,6 +286,16 @@ module Cask
|
||||
desc json_cask[:desc]
|
||||
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?
|
||||
conflicts_with(**json_cask[:conflicts_with]) if json_cask[:conflicts_with].present?
|
||||
|
||||
|
||||
@ -84,6 +84,14 @@ module Cask
|
||||
:url,
|
||||
:version,
|
||||
:appdir,
|
||||
:deprecate!,
|
||||
:deprecated?,
|
||||
:deprecation_date,
|
||||
:deprecation_reason,
|
||||
:disable!,
|
||||
:disabled?,
|
||||
:disable_date,
|
||||
:disable_reason,
|
||||
:discontinued?,
|
||||
:livecheck,
|
||||
:livecheckable?,
|
||||
@ -96,9 +104,9 @@ module Cask
|
||||
extend Predicable
|
||||
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)
|
||||
@cask = cask
|
||||
@ -316,9 +324,15 @@ module Cask
|
||||
end
|
||||
|
||||
def discontinued?
|
||||
# odeprecated "`discontinued?`", "`deprecated?` or `disabled?`"
|
||||
@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 }
|
||||
@ -337,8 +351,27 @@ module Cask
|
||||
@livecheck.instance_eval(&block)
|
||||
end
|
||||
|
||||
def livecheckable?
|
||||
@livecheckable == true
|
||||
# @api public
|
||||
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
|
||||
|
||||
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
||||
|
||||
@ -163,6 +163,7 @@ module Cask
|
||||
end
|
||||
|
||||
caveat :discontinued do
|
||||
# odeprecated "`caveats :discontinued`", "`deprecate!`"
|
||||
@discontinued = true
|
||||
<<~EOS
|
||||
#{@cask} has been officially discontinued upstream.
|
||||
|
||||
@ -54,6 +54,23 @@ module Cask
|
||||
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.
|
||||
#
|
||||
# @api private
|
||||
|
||||
@ -12,6 +12,8 @@ module Cask
|
||||
|
||||
output = +"#{title_info(cask)}\n"
|
||||
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)
|
||||
repo = repo_info(cask)
|
||||
output << "#{repo}\n" if repo
|
||||
|
||||
@ -93,6 +93,7 @@ module Cask
|
||||
old_config = @cask.config
|
||||
predecessor = @cask if reinstall? && @cask.installed?
|
||||
|
||||
check_deprecate_disable
|
||||
check_conflicts
|
||||
|
||||
print caveats
|
||||
@ -124,6 +125,18 @@ on_request: true)
|
||||
raise
|
||||
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
|
||||
return unless @cask.conflicts_with
|
||||
|
||||
|
||||
@ -278,14 +278,8 @@ module Homebrew
|
||||
puts formula.desc if formula.desc
|
||||
puts Formatter.url(formula.homepage) if formula.homepage
|
||||
|
||||
deprecate_disable_type, deprecate_disable_reason = DeprecateDisable.deprecate_disable_info formula
|
||||
if deprecate_disable_type.present?
|
||||
if deprecate_disable_reason.present?
|
||||
puts "#{deprecate_disable_type.capitalize} because it #{deprecate_disable_reason}!"
|
||||
else
|
||||
puts "#{deprecate_disable_type.capitalize}!"
|
||||
end
|
||||
end
|
||||
deprecate_disable_info_string = DeprecateDisable.message(formula)
|
||||
puts deprecate_disable_info_string.capitalize if deprecate_disable_info_string.present?
|
||||
|
||||
conflicts = formula.conflicts.map do |conflict|
|
||||
reason = " (because #{conflict.reason})" if conflict.reason
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
module DeprecateDisable
|
||||
module_function
|
||||
|
||||
DEPRECATE_DISABLE_REASONS = {
|
||||
FORMULA_DEPRECATE_DISABLE_REASONS = {
|
||||
does_not_build: "does not build",
|
||||
no_license: "has no license",
|
||||
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",
|
||||
}.freeze
|
||||
|
||||
def deprecate_disable_info(formula)
|
||||
if formula.deprecated?
|
||||
type = :deprecated
|
||||
reason = formula.deprecation_reason
|
||||
elsif formula.disabled?
|
||||
type = :disabled
|
||||
reason = formula.disable_reason
|
||||
else
|
||||
return
|
||||
CASK_DEPRECATE_DISABLE_REASONS = {
|
||||
discontinued: "is discontinued upstream",
|
||||
}.freeze
|
||||
|
||||
def type(formula_or_cask)
|
||||
return :deprecated if formula_or_cask.deprecated?
|
||||
|
||||
:disabled if formula_or_cask.disabled?
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@ -642,6 +642,18 @@ module Homebrew
|
||||
EOS
|
||||
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)) }
|
||||
def check_git_status
|
||||
return unless Utils::Git.available?
|
||||
|
||||
@ -3550,7 +3550,7 @@ class Formula
|
||||
# <pre>deprecate! date: "2020-08-27", because: :unmaintained</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 DeprecateDisable::DEPRECATE_DISABLE_REASONS
|
||||
# @see DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS
|
||||
def deprecate!(date:, because:)
|
||||
@deprecation_date = Date.parse(date)
|
||||
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: "has been replaced by foo"</pre>
|
||||
# @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:)
|
||||
@disable_date = Date.parse(date)
|
||||
|
||||
|
||||
@ -412,7 +412,7 @@ module Homebrew
|
||||
return if formula.disabled?
|
||||
|
||||
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
|
||||
#{formula.full_name} contains conflicting version recursive dependencies:
|
||||
|
||||
@ -200,21 +200,15 @@ class FormulaInstaller
|
||||
|
||||
sig { void }
|
||||
def prelude
|
||||
type, reason = DeprecateDisable.deprecate_disable_info formula
|
||||
if type.present?
|
||||
case type
|
||||
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
|
||||
deprecate_disable_type = DeprecateDisable.type(formula)
|
||||
if deprecate_disable_type.present?
|
||||
message = "#{formula.full_name} has been #{DeprecateDisable.message(formula)}"
|
||||
|
||||
raise CannotInstallFormulaError, "#{formula.full_name} has been disabled!"
|
||||
case deprecate_disable_type
|
||||
when :deprecated
|
||||
opoo message
|
||||
when :disabled
|
||||
raise CannotInstallFormulaError, message
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ require "tab"
|
||||
require "utils/bottles"
|
||||
require "service"
|
||||
require "utils/curl"
|
||||
require "deprecate_disable"
|
||||
|
||||
require "active_support/core_ext/hash/deep_transform_values"
|
||||
|
||||
@ -301,12 +302,12 @@ module Formulary
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
@ -462,13 +463,6 @@ module Formulary
|
||||
string
|
||||
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.
|
||||
# Subclasses implement loaders for particular sources of formulae.
|
||||
class FormulaLoader
|
||||
|
||||
@ -119,10 +119,24 @@ module Homebrew
|
||||
verbose: T::Boolean,
|
||||
).returns(Hash)
|
||||
}
|
||||
def cask_discontinued(cask, livecheckable, full_name: false, verbose: false)
|
||||
return {} if !cask.discontinued? || livecheckable
|
||||
def cask_deprecated(cask, livecheckable, full_name: false, verbose: false)
|
||||
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
|
||||
|
||||
sig {
|
||||
@ -165,7 +179,8 @@ module Homebrew
|
||||
# Skip conditions for casks.
|
||||
CASK_CHECKS = [
|
||||
:package_or_resource_skip,
|
||||
:cask_discontinued,
|
||||
:cask_deprecated,
|
||||
:cask_disabled,
|
||||
:cask_version_latest,
|
||||
:cask_url_unversioned,
|
||||
].freeze
|
||||
|
||||
@ -74,9 +74,9 @@ module RuboCop
|
||||
|
||||
Constants::STANZA_ORDER.each do |stanza_name|
|
||||
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
||||
def #{stanza_name}? # def url?
|
||||
stanza_name == :#{stanza_name} # stanza_name == :url
|
||||
end # end
|
||||
def #{stanza_name.to_s.chomp("!")}? # def url?
|
||||
stanza_name == :#{stanza_name} # stanza_name == :url
|
||||
end # end
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
|
||||
@ -19,6 +19,7 @@ module RuboCop
|
||||
[:language],
|
||||
[:url, :appcast, :name, :desc, :homepage],
|
||||
[:livecheck],
|
||||
[:deprecate!, :disable!],
|
||||
[
|
||||
:auto_updates,
|
||||
:conflicts_with,
|
||||
|
||||
89
Library/Homebrew/test/deprecate_disable_spec.rb
Normal file
89
Library/Homebrew/test/deprecate_disable_spec.rb
Normal 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
|
||||
@ -521,15 +521,4 @@ describe Formulary do
|
||||
expect(described_class.convert_to_string_or_symbol(":foo")).to eq :foo
|
||||
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
|
||||
|
||||
@ -104,6 +104,28 @@ describe Homebrew::Livecheck::SkipConditions do
|
||||
discontinued
|
||||
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
|
||||
version :latest
|
||||
sha256 :no_check
|
||||
@ -225,7 +247,21 @@ describe Homebrew::Livecheck::SkipConditions do
|
||||
cask: {
|
||||
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: {
|
||||
livecheckable: false,
|
||||
},
|
||||
@ -330,6 +366,20 @@ describe Homebrew::Livecheck::SkipConditions do
|
||||
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
|
||||
it "skips" do
|
||||
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
|
||||
it "errors" do
|
||||
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
|
||||
|
||||
@ -537,7 +601,23 @@ 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: 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
|
||||
end
|
||||
end
|
||||
|
||||
@ -90,6 +90,12 @@
|
||||
"type": "naked"
|
||||
},
|
||||
"auto_updates": true,
|
||||
"deprecated": false,
|
||||
"deprecation_date": null,
|
||||
"deprecation_reason": null,
|
||||
"disabled": false,
|
||||
"disable_date": null,
|
||||
"disable_reason": null,
|
||||
"tap_git_head": null,
|
||||
"languages": [
|
||||
"en",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user