From e5cfc0f37b778732a9f2999ba74d2d0bafd3003a Mon Sep 17 00:00:00 2001 From: Nanda H Krishna Date: Sun, 30 May 2021 21:53:17 +0530 Subject: [PATCH] livecheck/strategy/gnome: handle new GNOME versioning --- Library/Homebrew/livecheck/strategy/gnome.rb | 38 ++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/livecheck/strategy/gnome.rb b/Library/Homebrew/livecheck/strategy/gnome.rb index 3eb6442cf9..bf538adffd 100644 --- a/Library/Homebrew/livecheck/strategy/gnome.rb +++ b/Library/Homebrew/livecheck/strategy/gnome.rb @@ -12,8 +12,14 @@ module Homebrew # # * `https://download.gnome.org/sources/example/1.2/example-1.2.3.tar.xz` # - # The default regex restricts matching to filenames containing a version - # with an even-numbered minor below 90, as these are stable releases. + # For the new GNOME versioning scheme used with GNOME 40 and newer, the + # 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 class Gnome @@ -55,19 +61,23 @@ module Homebrew page_url = "https://download.gnome.org/sources/#{match[:package_name]}/cache.json" - # GNOME archive files seem to use a standard filename format, so we - # 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 - # matching to versions with an even-numbered minor, as these are - # 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 + if regex.blank? + # GNOME archive files seem to use a standard filename format, so we + # count on the delimiter between the package name and numeric + # version being a hyphen and the file being a tarball. + regex = /#{Regexp.escape(match[:package_name])}-(\d+(?:\.\d+)+)\.t/i + version_data = PageMatch.find_versions(page_url, regex, cask: cask, &block) - 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