Skip to content

Commit

Permalink
Merge pull request #14870 from nandahkrishna/fix-requirement
Browse files Browse the repository at this point in the history
Fix `{MacOS,Xcode}Requirement` handling and improve output
  • Loading branch information
MikeMcQuaid committed Mar 7, 2023
2 parents bd30950 + 5132963 commit 3e2c713
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions Library/Homebrew/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ def self.fetch_homebrew_cask_source(name, git_head: nil, sha256: nil)

sig { params(json: Hash).returns(Hash) }
def self.merge_variations(json)
if (bottle_tag = ::Utils::Bottles.tag.to_s.presence) &&
(variations = json["variations"].presence) &&
(variation = variations[bottle_tag].presence)
bottle_tag = ::Utils::Bottles::Tag.new(system: Homebrew::SimulateSystem.current_os,
arch: Homebrew::SimulateSystem.current_arch)

if (variations = json["variations"].presence) &&
(variation = variations[bottle_tag.to_s].presence)
json = json.merge(variation)
end

Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/dev-cmd/unbottled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "cli/parser"
require "formula"
require "api"
require "os/mac/xcode"

module Homebrew
extend T::Sig
Expand Down
14 changes: 7 additions & 7 deletions Library/Homebrew/requirements/macos_requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def initialize(tags = [], comparator: ">=")
end

def version_specified?
OS.mac? && @version
@version.present?
end

satisfy(build_env: false) do
T.bind(self, MacOSRequirement)
next Array(@version).any? { |v| MacOS.version.public_send(@comparator, v) } if version_specified?
next Array(@version).any? { |v| MacOS.version.public_send(@comparator, v) } if OS.mac? && version_specified?
next true if OS.mac?
next true if @version

Expand All @@ -68,7 +68,7 @@ def message(type: :formula)

case @comparator
when ">="
"macOS #{@version.pretty_name} or newer is required for this software."
"This software does not run on macOS versions older than #{@version.pretty_name}."
when "<="
case type
when :formula
Expand All @@ -82,10 +82,10 @@ def message(type: :formula)
else
if @version.respond_to?(:to_ary)
*versions, last = @version.map(&:pretty_name)
return "macOS #{versions.join(", ")} or #{last} is required for this software."
return "This software does not run on macOS versions other than #{versions.join(", ")} and #{last}."
end

"macOS #{@version.pretty_name} is required for this software."
"This software does not run on macOS versions other than #{@version.pretty_name}."
end
end

Expand All @@ -107,9 +107,9 @@ def inspect
def display_s
if version_specified?
if @version.respond_to?(:to_ary)
"macOS #{@comparator} #{version.join(" / ")}"
"macOS #{@comparator} #{version.join(" / ")} (or Linux)"
else
"macOS #{@comparator} #{@version}"
"macOS #{@comparator} #{@version} (or Linux)"
end
else
"macOS"
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/requirements/xcode_requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def inspect
end

def display_s
return name.capitalize unless @version
return "#{name.capitalize} (on macOS)" unless @version

"#{name.capitalize} >= #{@version}"
"#{name.capitalize} >= #{@version} (on macOS)"
end
end

Expand Down

0 comments on commit 3e2c713

Please sign in to comment.