Modify Gnome strategy and update comments

Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
This commit is contained in:
Nanda H Krishna 2021-05-31 16:07:56 +05:30
parent e5cfc0f37b
commit 471ce1541d
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA

View File

@ -12,14 +12,16 @@ 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`
# #
# For the new GNOME versioning scheme used with GNOME 40 and newer, the # Before version 40, GNOME used a versioning scheme where unstable
# strategy matches all versions with a numeric minor (and micro if # releases were indicated with a minor that's 90+ or odd. The newer
# present). This excludes versions like `40.alpha`, `40.beta` and `40.rc` # version scheme uses trailing alpha/beta/rc text to identify unstable
# which are development releases. # versions (e.g., `40.alpha`).
# #
# For the older GNOME versioning scheme used with major versions 3 and # When a regex isn't provided in a `livecheck` block, this strategy uses
# below, only those filenames containing a version with an even-numbered # a default regex that matches versions that don't include trailing text
# minor below 90 are matched, as these are stable releases. # after the numeric version (e.g., `40.0` instead of `40.alpha`, etc.)
# and it selectively filters out unstable versions below 40 using the
# older scheme.
# #
# @api public # @api public
class Gnome class Gnome
@ -68,10 +70,10 @@ module Homebrew
regex = /#{Regexp.escape(match[:package_name])}-(\d+(?:\.\d+)+)\.t/i regex = /#{Regexp.escape(match[:package_name])}-(\d+(?:\.\d+)+)\.t/i
version_data = PageMatch.find_versions(page_url, regex, cask: cask, &block) version_data = PageMatch.find_versions(page_url, regex, cask: cask, &block)
# Before GNOME 40, versions have a major equal to or less than 3. # Filter out unstable versions using the old version scheme where
# Stable versions have an even-numbered minor less than 90. # the major version is below 40.
version_data[:matches].select! do |_, version| version_data[:matches].reject! do |_, version|
(version.major <= 3 && version.minor.to_i.even? && version.minor < 90) || (version.major >= 40) version.major < 40 && (version.minor >= 90 || version.minor.to_i.odd?)
end end
version_data version_data