livecheck/strategy/gnome: handle new GNOME versioning

This commit is contained in:
Nanda H Krishna 2021-05-30 21:53:17 +05:30
parent 990d5f048f
commit e5cfc0f37b
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA

View File

@ -12,8 +12,14 @@ module Homebrew
# #
# * `https://download.gnome.org/sources/example/1.2/example-1.2.3.tar.xz` # * `https://download.gnome.org/sources/example/1.2/example-1.2.3.tar.xz`
# #
# The default regex restricts matching to filenames containing a version # For the new GNOME versioning scheme used with GNOME 40 and newer, the
# with an even-numbered minor below 90, as these are stable releases. # strategy matches all versions with a numeric minor (and micro if
# present). This excludes versions like `40.alpha`, `40.beta` and `40.rc`
# which are development releases.
#
# For the older GNOME versioning scheme used with major versions 3 and
# below, only those filenames containing a version with an even-numbered
# minor below 90 are matched, as these are stable releases.
# #
# @api public # @api public
class Gnome class Gnome
@ -55,19 +61,23 @@ module Homebrew
page_url = "https://download.gnome.org/sources/#{match[:package_name]}/cache.json" page_url = "https://download.gnome.org/sources/#{match[:package_name]}/cache.json"
# GNOME archive files seem to use a standard filename format, so we if regex.blank?
# count on the delimiter between the package name and numeric version # GNOME archive files seem to use a standard filename format, so we
# being a hyphen and the file being a tarball. # count on the delimiter between the package name and numeric
# # version being a hyphen and the file being a tarball.
# The `([0-8]\d*?)?[02468]` part of the regex is intended to restrict regex = /#{Regexp.escape(match[:package_name])}-(\d+(?:\.\d+)+)\.t/i
# matching to versions with an even-numbered minor, as these are version_data = PageMatch.find_versions(page_url, regex, cask: cask, &block)
# stable releases. This also excludes x.90+ versions, which are
# development versions. See: https://www.gnome.org/gnome-3/source/
#
# Example regex: `/example-(\d+\.([0-8]\d*?)?[02468](?:\.\d+)*?)\.t/i`
regex ||= /#{Regexp.escape(match[:package_name])}-(\d+\.([0-8]\d*?)?[02468](?:\.\d+)*?)\.t/i
PageMatch.find_versions(page_url, regex, cask: cask, &block) # Before GNOME 40, versions have a major equal to or less than 3.
# Stable versions have an even-numbered minor less than 90.
version_data[:matches].select! do |_, version|
(version.major <= 3 && version.minor.to_i.even? && version.minor < 90) || (version.major >= 40)
end
version_data
else
PageMatch.find_versions(page_url, regex, cask: cask, &block)
end
end end
end end
end end