Fix Sparkle strategy when only URLs but no versions are found.
This commit is contained in:
parent
347a58f164
commit
d5e1d004e8
@ -32,7 +32,13 @@ module Homebrew
|
|||||||
return false unless xml
|
return false unless xml
|
||||||
|
|
||||||
contents = Strategy.page_contents(url)
|
contents = Strategy.page_contents(url)
|
||||||
contents.match?(%r{https?://www.andymatuschak.org/xml-namespaces/sparkle})
|
|
||||||
|
return true if contents.match?(%r{https?://www.andymatuschak.org/xml-namespaces/sparkle})
|
||||||
|
|
||||||
|
contents.include?("rss") &&
|
||||||
|
contents.include?("channel") &&
|
||||||
|
contents.include?("item") &&
|
||||||
|
contents.include?("enclosure")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks the content at the URL for new versions.
|
# Checks the content at the URL for new versions.
|
||||||
@ -60,23 +66,25 @@ module Homebrew
|
|||||||
short_version ||= (item > "shortVersionString").first&.text
|
short_version ||= (item > "shortVersionString").first&.text
|
||||||
version ||= (item > "version").first&.text
|
version ||= (item > "version").first&.text
|
||||||
|
|
||||||
{
|
data = {
|
||||||
url: enclosure["url"],
|
url: enclosure["url"],
|
||||||
version: BundleVersion.new(short_version, version),
|
version: short_version || version ? BundleVersion.new(short_version, version) : nil,
|
||||||
}
|
}.compact
|
||||||
|
|
||||||
|
data unless data.empty?
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
item = items.max_by { |e| e[:version] }
|
item = items.max_by { |e| e[:version] }
|
||||||
|
|
||||||
if item
|
if item
|
||||||
match = if block
|
match = if block
|
||||||
item[:version] = item[:version].nice_version
|
item[:version] = item[:version]&.nice_version
|
||||||
block.call(item).to_s
|
block.call(item).to_s
|
||||||
else
|
else
|
||||||
item[:version].nice_version
|
item[:version]&.nice_version
|
||||||
end
|
end
|
||||||
|
|
||||||
match_data[:matches][match] = Version.new(match)
|
match_data[:matches][match] = Version.new(match) if match
|
||||||
end
|
end
|
||||||
|
|
||||||
match_data
|
match_data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user