search: show results by platform

This means that formulas that are only available on one
OS should only show up in the search results for the platform.
This commit is contained in:
apainintheneck 2023-03-27 19:35:28 -07:00
parent 140d444462
commit c073cf901a
4 changed files with 25 additions and 1 deletions

View File

@ -6,6 +6,7 @@ class Formula
undef loader_path
undef deuniversalize_machos
undef add_global_deps_to_spec
undef valid_platform?
sig { params(name: String, version: T.nilable(T.any(String, Integer))).returns(String) }
def shared_library(name, version = nil)
@ -43,4 +44,9 @@ class Formula
end
@global_deps.each { |dep| spec.dependency_collector.add(dep) }
end
sig { returns(T::Boolean) }
def valid_platform?
requirements.none?(MacOSRequirement)
end
end

View File

@ -0,0 +1,11 @@
# typed: true
# frozen_string_literal: true
class Formula
undef valid_platform?
sig { returns(T::Boolean) }
def valid_platform?
requirements.none?(LinuxRequirement)
end
end

View File

@ -1948,6 +1948,13 @@ class Formula
!tap.core_tap?
end
# True if this formula can be installed on this platform
# Redefined in extend/os.
# @private
def valid_platform?
requirements.none?(MacOSRequirement) && requirements.none?(LinuxRequirement)
end
# @private
def print_tap_action(options = {})
return unless tap?

View File

@ -113,7 +113,7 @@ module Homebrew
if formula&.any_version_installed?
pretty_installed(name)
else
elsif formula.nil? || formula.valid_platform?
name
end
end.compact