Merge pull request #14870 from nandahkrishna/fix-requirement
Fix `{MacOS,Xcode}Requirement` handling and improve output
This commit is contained in:
commit
3e2c713c92
@ -159,9 +159,11 @@ module Homebrew
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
require "cli/parser"
|
||||
require "formula"
|
||||
require "api"
|
||||
require "os/mac/xcode"
|
||||
|
||||
module Homebrew
|
||||
extend T::Sig
|
||||
|
||||
@ -51,12 +51,12 @@ class MacOSRequirement < Requirement
|
||||
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
|
||||
|
||||
@ -68,7 +68,7 @@ class MacOSRequirement < Requirement
|
||||
|
||||
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
|
||||
@ -82,10 +82,10 @@ class MacOSRequirement < Requirement
|
||||
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
|
||||
|
||||
@ -107,9 +107,9 @@ class MacOSRequirement < Requirement
|
||||
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"
|
||||
|
||||
@ -58,9 +58,9 @@ class XcodeRequirement < Requirement
|
||||
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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user