Merge pull request #15072 from apainintheneck/search-by-platform

search: show results by platform
This commit is contained in:
Mike McQuaid 2023-03-28 09:07:46 +01:00 committed by GitHub
commit eef6e9bf05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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