Skip to content

Commit

Permalink
Merge pull request Homebrew#11171 from reitermarkus/sparkle-latest
Browse files Browse the repository at this point in the history
Always take latest item in `Sparkle` strategy.
  • Loading branch information
reitermarkus authored Apr 17, 2021
2 parents 842a2ea + 9bb1ba3 commit d6e5973
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Library/Homebrew/livecheck/strategy/sparkle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def self.match?(url)
Item = Struct.new(
# @api public
:title,
# @api private
:pub_date,
# @api public
:url,
# @api private
Expand Down Expand Up @@ -72,6 +74,7 @@ def self.item_from_content(content)
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]
Expand All @@ -84,14 +87,15 @@ def self.item_from_content(content)

data = {
title: title,
pub_date: pub_date,
url: url,
bundle_version: bundle_version,
}.compact

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.
Expand Down

0 comments on commit d6e5973

Please sign in to comment.