Merge pull request #8512 from Rylan12/disable-deprecation-reason
disable!, deprecate!: add reason
This commit is contained in:
commit
fa436561d7
@ -1148,12 +1148,24 @@ class Formula
|
|||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
delegate deprecated?: :"self.class"
|
delegate deprecated?: :"self.class"
|
||||||
|
|
||||||
|
# The reason this {Formula} is deprecated.
|
||||||
|
# Returns `nil` if no reason is specified or the formula is not deprecated.
|
||||||
|
# @method deprecation_reason
|
||||||
|
# @return [String]
|
||||||
|
delegate deprecation_reason: :"self.class"
|
||||||
|
|
||||||
# Whether this {Formula} is disabled (i.e. cannot be installed).
|
# Whether this {Formula} is disabled (i.e. cannot be installed).
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
# @method disabled?
|
# @method disabled?
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
delegate disabled?: :"self.class"
|
delegate disabled?: :"self.class"
|
||||||
|
|
||||||
|
# The reason this {Formula} is disabled.
|
||||||
|
# Returns `nil` if no reason is specified or the formula is not disabled.
|
||||||
|
# @method disable_reason
|
||||||
|
# @return [String]
|
||||||
|
delegate disable_reason: :"self.class"
|
||||||
|
|
||||||
def skip_cxxstdlib_check?
|
def skip_cxxstdlib_check?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
@ -2766,9 +2778,14 @@ class Formula
|
|||||||
# Deprecates a {Formula} (on a given date, if provided) so a warning is
|
# Deprecates a {Formula} (on a given date, if provided) so a warning is
|
||||||
# shown on each installation. If the date has not yet passed the formula
|
# shown on each installation. If the date has not yet passed the formula
|
||||||
# will not be deprecated.
|
# will not be deprecated.
|
||||||
def deprecate!(date: nil)
|
# <pre>deprecate! date: "2020-08-27", because: "it is no longer maintained"</pre>
|
||||||
|
def deprecate!(date: nil, because: nil)
|
||||||
|
# TODO: enable for next major/minor release
|
||||||
|
# odeprecated "`deprecate!` without a reason", "`deprecate! because: \"reason\"`" if because.blank?
|
||||||
|
|
||||||
return if date.present? && Date.parse(date) > Date.today
|
return if date.present? && Date.parse(date) > Date.today
|
||||||
|
|
||||||
|
@deprecation_reason = because if because.present?
|
||||||
@deprecated = true
|
@deprecated = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2779,15 +2796,26 @@ class Formula
|
|||||||
@deprecated == true
|
@deprecated == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The reason for deprecation of a {Formula}.
|
||||||
|
# Returns `nil` if no reason was provided or the formula is not deprecated.
|
||||||
|
# @return [String]
|
||||||
|
attr_reader :deprecation_reason
|
||||||
|
|
||||||
# Disables a {Formula} (on a given date, if provided) so it cannot be
|
# Disables a {Formula} (on a given date, if provided) so it cannot be
|
||||||
# installed. If the date has not yet passed the formula
|
# installed. If the date has not yet passed the formula
|
||||||
# will be deprecated instead of disabled.
|
# will be deprecated instead of disabled.
|
||||||
def disable!(date: nil)
|
# <pre>disable! date: "2020-08-27", because: "it no longer builds"</pre>
|
||||||
|
def disable!(date: nil, because: nil)
|
||||||
|
# TODO: enable for next major/minor release
|
||||||
|
# odeprecated "`disable!` without a reason", "`disable! because: \"reason\"`" if because.blank?
|
||||||
|
|
||||||
if date.present? && Date.parse(date) > Date.today
|
if date.present? && Date.parse(date) > Date.today
|
||||||
|
@deprecation_reason = because if because.present?
|
||||||
@deprecated = true
|
@deprecated = true
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@disable_reason = because if because.present?
|
||||||
@disabled = true
|
@disabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2798,6 +2826,11 @@ class Formula
|
|||||||
@disabled == true
|
@disabled == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The reason for a {Formula} is disabled.
|
||||||
|
# Returns `nil` if no reason was provided or the formula is not disabled.
|
||||||
|
# @return [String]
|
||||||
|
attr_reader :disable_reason
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def link_overwrite(*paths)
|
def link_overwrite(*paths)
|
||||||
paths.flatten!
|
paths.flatten!
|
||||||
|
|||||||
@ -203,10 +203,18 @@ class FormulaInstaller
|
|||||||
raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula)
|
raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula)
|
||||||
|
|
||||||
if formula.deprecated?
|
if formula.deprecated?
|
||||||
|
if formula.deprecation_reason.present?
|
||||||
|
opoo "#{formula.full_name} has been deprecated because #{formula.deprecation_reason}!"
|
||||||
|
else
|
||||||
opoo "#{formula.full_name} has been deprecated!"
|
opoo "#{formula.full_name} has been deprecated!"
|
||||||
|
end
|
||||||
elsif formula.disabled?
|
elsif formula.disabled?
|
||||||
|
if formula.disable_reason.present?
|
||||||
|
odie "#{formula.full_name} has been disabled because #{formula.disable_reason}!"
|
||||||
|
else
|
||||||
odie "#{formula.full_name} has been disabled!"
|
odie "#{formula.full_name} has been disabled!"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return if ignore_deps?
|
return if ignore_deps?
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user