Merge pull request #18034 from chenrui333/fix-product-eol-check

This commit is contained in:
Issy Long 2024-08-13 09:58:33 +01:00 committed by GitHub
commit 190912527d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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?