mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
tap: memoize allowed and forbidden taps
This commit is contained in:
parent
34e2c4ee97
commit
7c9e8927e9
@ -132,29 +132,40 @@ class Tap
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop:disable Style/ClassVars
|
||||||
|
# We want the the class variables below to be global to all `Tap` classes and subclasses.
|
||||||
sig { returns(T::Set[Tap]) }
|
sig { returns(T::Set[Tap]) }
|
||||||
def self.allowed_taps
|
def self.allowed_taps
|
||||||
allowed_tap_list = Homebrew::EnvConfig.allowed_taps.to_s.split
|
@@allowed_taps ||= begin
|
||||||
|
allowed_tap_list = Homebrew::EnvConfig.allowed_taps.to_s.split
|
||||||
|
|
||||||
Set.new(allowed_tap_list.filter_map do |tap|
|
Set.new(allowed_tap_list.filter_map do |tap|
|
||||||
Tap.fetch(tap)
|
Tap.fetch(tap)
|
||||||
rescue Tap::InvalidNameError
|
rescue Tap::InvalidNameError
|
||||||
opoo "Invalid tap name in `HOMEBREW_ALLOWED_TAPS`: #{tap}"
|
opoo "Invalid tap name in `HOMEBREW_ALLOWED_TAPS`: #{tap}"
|
||||||
nil
|
nil
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
@@allowed_taps.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Set[Tap]) }
|
sig { returns(T::Set[Tap]) }
|
||||||
def self.forbidden_taps
|
def self.forbidden_taps
|
||||||
forbidden_tap_list = Homebrew::EnvConfig.forbidden_taps.to_s.split
|
@@forbidden_taps ||= begin
|
||||||
|
forbidden_tap_list = Homebrew::EnvConfig.forbidden_taps.to_s.split
|
||||||
|
|
||||||
Set.new(forbidden_tap_list.filter_map do |tap|
|
Set.new(forbidden_tap_list.filter_map do |tap|
|
||||||
Tap.fetch(tap)
|
Tap.fetch(tap)
|
||||||
rescue Tap::InvalidNameError
|
rescue Tap::InvalidNameError
|
||||||
opoo "Invalid tap name in `HOMEBREW_FORBIDDEN_TAPS`: #{tap}"
|
opoo "Invalid tap name in `HOMEBREW_FORBIDDEN_TAPS`: #{tap}"
|
||||||
nil
|
nil
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
@@forbidden_taps.freeze
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Style/ClassVars
|
||||||
|
|
||||||
# @api public
|
# @api public
|
||||||
extend Enumerable
|
extend Enumerable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user