Skip to content

Commit

Permalink
cask: skip variations for inapplicable versions
Browse files Browse the repository at this point in the history
  • Loading branch information
EricFromCanada committed May 29, 2024
1 parent cd65109 commit c712902
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Library/Homebrew/cask/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ def to_hash_with_variations(hash_method: :to_h)
MacOSVersion::SYMBOLS.keys.product(OnSystem::ARCH_OPTIONS).each do |os, arch|
bottle_tag = ::Utils::Bottles::Tag.new(system: os, arch:)
next unless bottle_tag.valid_combination?
next if depends_on.macos && !bottle_tag.to_macos_version.compare(depends_on.macos.comparator,
depends_on.macos.version)

Homebrew::SimulateSystem.with(os:, arch:) do
refresh
Expand Down
18 changes: 18 additions & 0 deletions Library/Homebrew/macos_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ def <=>(other)
result
end

sig { params(comparator: String, other: T.any(Version, T::Array[MacOSVersion])).returns(T::Boolean) }
def compare(comparator, other)
if other.is_a?(Version)
super
else
case comparator
when "==" then other.include?(self)
when "!=" then other.exclude?(self)
else raise ArgumentError, "Unsupported comparator for Array input: #{comparator}"
end
end
end

sig { returns(T.self_type) }
def strip_patch
return self if null?
Expand Down Expand Up @@ -100,6 +113,11 @@ def pretty_name
pretty_name
end

sig { returns(String) }
def inspect
"#<#{self.class.name}: #{to_s.inspect}>"

Check warning on line 118 in Library/Homebrew/macos_version.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/macos_version.rb#L118

Added line #L118 was not covered by tests
end

sig { returns(T::Boolean) }
def outdated_release?
self < HOMEBREW_MACOS_OLDEST_SUPPORTED
Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/test/macos_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
end
end

specify "#compare" do
expect(version.compare("==", [described_class.new("10.13"), described_class.new("10.14")])).to be true
expect(version.compare("!=", [described_class.new("10.13"), described_class.new("11.0")])).to be true
end

specify "#pretty_name" do
expect(described_class.new("10.11").pretty_name).to eq("El Capitan")
expect(described_class.new("10.14").pretty_name).to eq("Mojave")
Expand Down

0 comments on commit c712902

Please sign in to comment.