cmd/readall: Cleanup todos

- keep running the command against all os/arch combinations
  as the default
- remove todos and deprecations related to changing the behavior
- create constants for os/arch combinations
This commit is contained in:
apainintheneck 2023-09-19 21:33:13 -07:00
parent aa2a77b1f1
commit 5760ae4fb2
7 changed files with 12 additions and 23 deletions

View File

@ -111,10 +111,7 @@ module Homebrew
when :all when :all
skip_invalid_combinations = true skip_invalid_combinations = true
[ OnSystem::ALL_OS_OPTIONS
*MacOSVersion::SYMBOLS.keys,
:linux,
]
else else
[os_sym] [os_sym]
end end

View File

@ -38,8 +38,6 @@ module Homebrew
def readall def readall
args = readall_args.parse args = readall_args.parse
odeprecated "--no-simulate", "nothing (i.e. not passing `--os` or `--arch`)" if args.no_simulate?
if args.syntax? && args.no_named? if args.syntax? && args.no_named?
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb" scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"
ruby_files = Dir.glob(scan_files).grep_v(%r{/(vendor)/}) ruby_files = Dir.glob(scan_files).grep_v(%r{/(vendor)/})
@ -51,8 +49,8 @@ module Homebrew
aliases: args.aliases?, aliases: args.aliases?,
no_simulate: args.no_simulate?, no_simulate: args.no_simulate?,
} }
# TODO: Always pass this once `--os` and `--arch` are passed explicitly to `brew readall` in CI.
options[:os_arch_combinations] = args.os_arch_combinations if args.os || args.arch options[:os_arch_combinations] = args.os_arch_combinations if args.os || args.arch
taps = if args.no_named? taps = if args.no_named?
if !args.eval_all? && !Homebrew::EnvConfig.eval_all? if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
raise UsageError, "`brew readall` needs a tap or `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!" raise UsageError, "`brew readall` needs a tap or `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
@ -62,6 +60,7 @@ module Homebrew
else else
args.named.to_installed_taps args.named.to_installed_taps
end end
taps.each do |tap| taps.each do |tap|
Homebrew.failed = true unless Readall.valid_tap?(tap, options) Homebrew.failed = true unless Readall.valid_tap?(tap, options)
end end

View File

@ -6,6 +6,8 @@ require "simulate_system"
module OnSystem module OnSystem
ARCH_OPTIONS = [:intel, :arm].freeze ARCH_OPTIONS = [:intel, :arm].freeze
BASE_OS_OPTIONS = [:macos, :linux].freeze BASE_OS_OPTIONS = [:macos, :linux].freeze
ALL_OS_OPTIONS = [*MacOSVersion::SYMBOLS.keys, :linux].freeze
ALL_OS_ARCH_COMBINATIONS = ALL_OS_OPTIONS.product(ARCH_OPTIONS).freeze
sig { params(arch: Symbol).returns(T::Boolean) } sig { params(arch: Symbol).returns(T::Boolean) }
def self.arch_condition_met?(arch) def self.arch_condition_met?(arch)

View File

@ -2398,11 +2398,9 @@ class Formula
variations = {} variations = {}
os_versions = [*MacOSVersion::SYMBOLS.keys, :linux]
if path.exist? && (self.class.on_system_blocks_exist? || @on_system_blocks_exist) if path.exist? && (self.class.on_system_blocks_exist? || @on_system_blocks_exist)
formula_contents = path.read formula_contents = path.read
os_versions.product(OnSystem::ARCH_OPTIONS).each do |os, arch| OnSystem::ALL_OS_ARCH_COMBINATIONS.each do |os, arch|
bottle_tag = Utils::Bottles::Tag.new(system: os, arch: arch) bottle_tag = Utils::Bottles::Tag.new(system: os, arch: arch)
next unless bottle_tag.valid_combination? next unless bottle_tag.valid_combination?

View File

@ -66,20 +66,18 @@ module Readall
true true
end end
def valid_tap?(tap, aliases: false, no_simulate: false, os_arch_combinations: nil) def valid_tap?(tap, aliases: false, no_simulate: false, os_arch_combinations: OnSystem::ALL_OS_ARCH_COMBINATIONS)
success = true success = true
if aliases if aliases
valid_aliases = valid_aliases?(tap.alias_dir, tap.formula_dir) valid_aliases = valid_aliases?(tap.alias_dir, tap.formula_dir)
success = false unless valid_aliases success = false unless valid_aliases
end end
if no_simulate if no_simulate
success = false unless valid_formulae?(tap.formula_files) success = false unless valid_formulae?(tap.formula_files)
success = false unless valid_casks?(tap.cask_files) success = false unless valid_casks?(tap.cask_files)
else else
# TODO: Remove this default case once `--os` and `--arch` are passed explicitly to `brew readall` in CI.
os_arch_combinations ||= [*MacOSVersion::SYMBOLS.keys, :linux].product(OnSystem::ARCH_OPTIONS)
os_arch_combinations.each do |os, arch| os_arch_combinations.each do |os, arch|
bottle_tag = Utils::Bottles::Tag.new(system: os, arch: arch) bottle_tag = Utils::Bottles::Tag.new(system: os, arch: arch)
next unless bottle_tag.valid_combination? next unless bottle_tag.valid_combination?

View File

@ -342,7 +342,7 @@ class Tap
begin begin
safe_system "git", *args safe_system "git", *args
if verify && !Readall.valid_tap?(self, aliases: true) && !Homebrew::EnvConfig.developer? if verify && !Homebrew::EnvConfig.developer? && !Readall.valid_tap?(self, aliases: true)
raise "Cannot tap #{name}: invalid syntax in tap!" raise "Cannot tap #{name}: invalid syntax in tap!"
end end
rescue Interrupt, RuntimeError rescue Interrupt, RuntimeError

View File

@ -1027,14 +1027,9 @@ describe Formula do
end end
before do before do
# Use a more limited symbols list to shorten the variations hash # Use a more limited os list to shorten the variations hash
symbols = { os_list = [:monterey, :big_sur, :catalina, :mojave, :linux]
monterey: "12", stub_const("OnSystem::ALL_OS_ARCH_COMBINATIONS", os_list.product(OnSystem::ARCH_OPTIONS))
big_sur: "11",
catalina: "10.15",
mojave: "10.14",
}
stub_const("MacOSVersion::SYMBOLS", symbols)
# For consistency, always run on Monterey and ARM # For consistency, always run on Monterey and ARM
allow(MacOS).to receive(:version).and_return(MacOSVersion.new("12")) allow(MacOS).to receive(:version).and_return(MacOSVersion.new("12"))