From 9bb1ba324f339583e47b8c120a9ecfe31f07f764 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 15 Apr 2021 01:15:47 +0200 Subject: [PATCH] Always take latest item in `Sparkle` strategy. --- Library/Homebrew/livecheck/strategy/sparkle.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index bb5320aa8a..688f08aad2 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -36,6 +36,8 @@ module Homebrew Item = Struct.new( # @api public :title, + # @api private + :pub_date, # @api public :url, # @api private @@ -72,6 +74,7 @@ module Homebrew version ||= (item > "version").first&.text&.strip title = (item > "title").first&.text&.strip + pub_date = (item > "pubDate").first&.text&.strip&.yield_self { |d| Time.parse(d) } if (match = title&.match(/(\d+(?:\.\d+)*)\s*(\([^)]+\))?\Z/)) short_version ||= match[1] @@ -84,6 +87,7 @@ module Homebrew data = { title: title, + pub_date: pub_date, url: url, bundle_version: bundle_version, }.compact @@ -91,7 +95,7 @@ module Homebrew Item.new(**data) unless data.empty? end.compact - items.first + items.max_by { |item| [item.pub_date, item.bundle_version] } end # Checks the content at the URL for new versions.