From ebba3698877b6beb14fdaf2f8f420c7b99c913df Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 20 Jan 2021 12:02:24 -0500 Subject: [PATCH] Tap: add untapped_official_taps method --- Library/Homebrew/brew.rb | 3 +-- Library/Homebrew/extend/os/mac/tap.rb | 3 +-- Library/Homebrew/tap.rb | 11 ++++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index be7af80553..4edc7d5a2a 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -132,8 +132,7 @@ begin possible_tap = OFFICIAL_CMD_TAPS.find { |_, cmds| cmds.include?(cmd) } possible_tap = Tap.fetch(possible_tap.first) if possible_tap - untapped_official_taps = Homebrew::Settings.read(:untapped)&.split(";") || [] - if !possible_tap || possible_tap.installed? || untapped_official_taps.include?(possible_tap.name) + if !possible_tap || possible_tap.installed? || Tap.untapped_official_taps.include?(possible_tap.name) odie "Unknown command: #{cmd}" end diff --git a/Library/Homebrew/extend/os/mac/tap.rb b/Library/Homebrew/extend/os/mac/tap.rb index e64fc7cfc9..25dcb2042f 100644 --- a/Library/Homebrew/extend/os/mac/tap.rb +++ b/Library/Homebrew/extend/os/mac/tap.rb @@ -5,8 +5,7 @@ class Tap def self.install_default_cask_tap_if_necessary return false if default_cask_tap.installed? - untapped_official_taps = Homebrew::Settings.read(:untapped)&.split(";") || [] - return false if untapped_official_taps.include?(default_cask_tap.name) + return false if Tap.untapped_official_taps.include?(default_cask_tap.name) default_cask_tap.install true diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 3580d5e41f..bbf73c37a8 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -327,7 +327,7 @@ class Tap end if official? - untapped = Homebrew::Settings.read(:untapped)&.split(";") || [] + untapped = self.class.untapped_official_taps untapped -= [name] if untapped.empty? @@ -388,8 +388,7 @@ class Tap return unless official? - untapped = Homebrew::Settings.read(:untapped)&.split(";") || [] - + untapped = self.class.untapped_official_taps return if untapped.include? name untapped << name @@ -644,6 +643,12 @@ class Tap Pathname.glob TAP_DIRECTORY/"*/*/cmd" end + # An array of official taps that have been manually untapped + sig { returns(T::Array[String]) } + def self.untapped_official_taps + Homebrew::Settings.read(:untapped)&.split(";") || [] + end + # @private def formula_file_to_name(file) "#{name}/#{file.basename(".rb")}"