formula_auditor: fix eol check
Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
This commit is contained in:
parent
aad48a01db
commit
1270eb37b1
@ -587,10 +587,14 @@ module Homebrew
|
||||
metadata = SharedAudits.eol_data(name, formula.version.major)
|
||||
metadata ||= SharedAudits.eol_data(name, formula.version.major_minor)
|
||||
|
||||
return if metadata.blank? || (eol_date = metadata["eol"]).blank?
|
||||
return if metadata.blank? || (eol = metadata["eol"]).blank?
|
||||
|
||||
is_eol = eol == true
|
||||
is_eol ||= eol.is_a?(String) && (eol_date = Date.parse(eol)) <= Date.today
|
||||
return unless is_eol
|
||||
|
||||
message = "Product is EOL"
|
||||
message += " since #{eol_date}" if Date.parse(eol_date.to_s) <= Date.today
|
||||
message += " since #{eol_date}" if eol_date.present?
|
||||
message += ", see #{Formatter.url("https://endoflife.date/#{name}")}"
|
||||
|
||||
problem message
|
||||
|
||||
@ -10,9 +10,9 @@ module SharedAudits
|
||||
|
||||
module_function
|
||||
|
||||
sig { params(product: String, cycle: String).returns(T.nilable(T::Hash[String, T::Hash[Symbol, T.untyped]])) }
|
||||
sig { params(product: String, cycle: String).returns(T.nilable(T::Hash[String, T.untyped])) }
|
||||
def eol_data(product, cycle)
|
||||
@eol_data ||= T.let({}, T.nilable(T::Hash[String, T::Hash[String, T.untyped]]))
|
||||
@eol_data ||= T.let({}, T.nilable(T::Hash[String, T.untyped]))
|
||||
@eol_data["#{product}/#{cycle}"] ||= begin
|
||||
out, _, status = Utils::Curl.curl_output("--location", "https://endoflife.date/api/#{product}/#{cycle}.json")
|
||||
json = JSON.parse(out) if status.success?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user