os/mac/version: remove Yosemite.

It's no longer possible to run Homebrew there.

Co-authored-by: Bo Anderson <mail@boanderson.me>
This commit is contained in:
Mike McQuaid 2022-06-03 19:42:36 +01:00 committed by Bo Anderson
parent 5bc29fa77b
commit f43e9b6c04
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 41 additions and 14 deletions

View File

@ -13,6 +13,8 @@ module OS
class Version < ::Version class Version < ::Version
extend T::Sig extend T::Sig
# TODO: when removing symbols here, ensure that they are added to
# DEPRECATED_MACOS_VERSIONS in MacOSRequirement.
SYMBOLS = { SYMBOLS = {
monterey: "12", monterey: "12",
big_sur: "11", big_sur: "11",
@ -21,22 +23,21 @@ module OS
high_sierra: "10.13", high_sierra: "10.13",
sierra: "10.12", sierra: "10.12",
el_capitan: "10.11", el_capitan: "10.11",
# TODO: remove after 3.5.0 has been shipped and this is implicitly
# odisabled and we've cleaned up all tap references.
yosemite: "10.10",
}.freeze }.freeze
# TODO: bump version when new macOS is released or announced # TODO: bump version when new macOS is released or announced
# and also update references in docs/Installation.md and # and also update references in docs/Installation.md and
# https://github.com/Homebrew/install/blob/HEAD/install.sh # https://github.com/Homebrew/install/blob/HEAD/install.sh
MACOS_NEWEST_UNSUPPORTED = "13" NEWEST_UNSUPPORTED = "13"
private_constant :MACOS_NEWEST_UNSUPPORTED private_constant :NEWEST_UNSUPPORTED
# TODO: bump version when new macOS is released and also update # TODO: bump version when new macOS is released and also update
# references in docs/Installation.md and # references in docs/Installation.md and
# https://github.com/Homebrew/install/blob/HEAD/install.sh # https://github.com/Homebrew/install/blob/HEAD/install.sh
MACOS_OLDEST_SUPPORTED = "10.15" OLDEST_SUPPORTED = "10.15"
private_constant :MACOS_OLDEST_SUPPORTED private_constant :OLDEST_SUPPORTED
OLDEST_ALLOWED = "10.11"
sig { params(version: Symbol).returns(T.attached_class) } sig { params(version: Symbol).returns(T.attached_class) }
def self.from_symbol(version) def self.from_symbol(version)
@ -89,12 +90,12 @@ module OS
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def outdated_release? def outdated_release?
self < MACOS_OLDEST_SUPPORTED self < OLDEST_SUPPORTED
end end
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def prerelease? def prerelease?
self >= MACOS_NEWEST_UNSUPPORTED self >= NEWEST_UNSUPPORTED
end end
# For {OS::Mac::Version} compatibility. # For {OS::Mac::Version} compatibility.

View File

@ -13,15 +13,41 @@ class MacOSRequirement < Requirement
attr_reader :comparator, :version attr_reader :comparator, :version
# TODO: when Yosemite is removed here, keep these around as empty arrays so we
# can keep the deprecation/disabling code the same.
DISABLED_MACOS_VERSIONS = [].freeze
DEPRECATED_MACOS_VERSIONS = [
:yosemite,
].freeze
def initialize(tags = [], comparator: ">=") def initialize(tags = [], comparator: ">=")
@version = if comparator == "==" && tags.first.respond_to?(:map) @version = begin
tags.shift.map { |s| MacOS::Version.from_symbol(s) } if comparator == "==" && tags.first.respond_to?(:map)
else tags.first.map { |s| MacOS::Version.from_symbol(s) }
MacOS::Version.from_symbol(tags.shift) unless tags.empty? else
MacOS::Version.from_symbol(tags.first) unless tags.empty?
end
rescue MacOSVersionError => e
if DISABLED_MACOS_VERSIONS.include?(e.version)
odisabled "depends_on :macos => :#{e.version}"
elsif DEPRECATED_MACOS_VERSIONS.include?(e.version)
odeprecated "depends_on :macos => :#{e.version}"
else
raise
end
# Array of versions: remove the bad ones and try again.
if tags.first.respond_to?(:reject)
tags = [tags.first.reject { |s| s == e.version }, tags[1..]]
retry
end
# Otherwise fallback to the oldest allowed if comparator is >=.
MacOS::Version.new(MacOS::Version::OLDEST_ALLOWED) if comparator == ">="
end end
@comparator = comparator @comparator = comparator
super(tags) super(tags.drop(1))
end end
def version_specified? def version_specified?