Fix RuboCop failures.
Co-authored-by: Patrick Linnane <patrick@linnane.io> Co-authored-by: Carlo Cabrera <github@carlo.cab> Co-authored-by: Thierry Moisan <thierry.moisan@gmail.com> Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
6a5a48de29
commit
4513a43d53
@ -216,6 +216,10 @@ Naming/MethodParameterName:
|
|||||||
merge:
|
merge:
|
||||||
- AllowedNames
|
- AllowedNames
|
||||||
|
|
||||||
|
# Allows a nicer API for boolean methods with side effects.
|
||||||
|
Naming/PredicateMethod:
|
||||||
|
AllowBangMethods: true
|
||||||
|
|
||||||
# Both styles are used depending on context,
|
# Both styles are used depending on context,
|
||||||
# e.g. `sha256` and `something_countable_1`.
|
# e.g. `sha256` and `something_countable_1`.
|
||||||
Naming/VariableNumber:
|
Naming/VariableNumber:
|
||||||
|
|||||||
@ -10,7 +10,13 @@ Homebrew/MoveToExtendOS:
|
|||||||
- "{extend,test,requirements}/**/*"
|
- "{extend,test,requirements}/**/*"
|
||||||
- "os.rb"
|
- "os.rb"
|
||||||
|
|
||||||
Naming/PredicateName:
|
# We don't use Sorbet for RSpec tests so let's disable this there.
|
||||||
|
Sorbet/BlockMethodDefinition:
|
||||||
|
Exclude:
|
||||||
|
- test/**/*
|
||||||
|
|
||||||
|
# Want to preserve our own API for these methods for now.
|
||||||
|
Naming/PredicatePrefix:
|
||||||
inherit_mode:
|
inherit_mode:
|
||||||
merge:
|
merge:
|
||||||
- AllowedMethods
|
- AllowedMethods
|
||||||
|
|||||||
@ -142,7 +142,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { params(names: T::Array[String], type: String, regenerate: T::Boolean).returns(T::Boolean) }
|
sig { params(names: T::Array[String], type: String, regenerate: T::Boolean).returns(T::Boolean) }
|
||||||
def self.write_names_file(names, type, regenerate:)
|
def self.write_names_file!(names, type, regenerate:)
|
||||||
names_path = HOMEBREW_CACHE_API/"#{type}_names.txt"
|
names_path = HOMEBREW_CACHE_API/"#{type}_names.txt"
|
||||||
if !names_path.exist? || regenerate
|
if !names_path.exist? || regenerate
|
||||||
names_path.write(names.join("\n"))
|
names_path.write(names.join("\n"))
|
||||||
|
|||||||
@ -28,7 +28,7 @@ module Homebrew
|
|||||||
|
|
||||||
sig { params(cask: ::Cask::Cask).returns(::Cask::Cask) }
|
sig { params(cask: ::Cask::Cask).returns(::Cask::Cask) }
|
||||||
def self.source_download(cask)
|
def self.source_download(cask)
|
||||||
path = cask.ruby_source_path.to_s || "Casks/#{cask.token}.rb"
|
path = cask.ruby_source_path.to_s
|
||||||
sha256 = cask.ruby_source_checksum[:sha256]
|
sha256 = cask.ruby_source_checksum[:sha256]
|
||||||
checksum = Checksum.new(sha256) if sha256
|
checksum = Checksum.new(sha256) if sha256
|
||||||
git_head = cask.tap_git_head || "HEAD"
|
git_head = cask.tap_git_head || "HEAD"
|
||||||
@ -95,7 +95,7 @@ module Homebrew
|
|||||||
def self.write_names(regenerate: false)
|
def self.write_names(regenerate: false)
|
||||||
download_and_cache_data! unless cache.key?("casks")
|
download_and_cache_data! unless cache.key?("casks")
|
||||||
|
|
||||||
Homebrew::API.write_names_file(all_casks.keys, "cask", regenerate:)
|
Homebrew::API.write_names_file!(all_casks.keys, "cask", regenerate:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -129,7 +129,7 @@ module Homebrew
|
|||||||
def self.write_names_and_aliases(regenerate: false)
|
def self.write_names_and_aliases(regenerate: false)
|
||||||
download_and_cache_data! unless cache.key?("formulae")
|
download_and_cache_data! unless cache.key?("formulae")
|
||||||
|
|
||||||
return unless Homebrew::API.write_names_file(all_formulae.keys, "formula", regenerate:)
|
return unless Homebrew::API.write_names_file!(all_formulae.keys, "formula", regenerate:)
|
||||||
|
|
||||||
(HOMEBREW_CACHE_API/"formula_aliases.txt").open("w") do |file|
|
(HOMEBREW_CACHE_API/"formula_aliases.txt").open("w") do |file|
|
||||||
all_aliases.each do |alias_name, real_name|
|
all_aliases.each do |alias_name, real_name|
|
||||||
|
|||||||
@ -91,7 +91,7 @@ class Bottle
|
|||||||
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
|
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
|
||||||
resource.fetch(verify_download_integrity:, timeout:, quiet:)
|
resource.fetch(verify_download_integrity:, timeout:, quiet:)
|
||||||
rescue DownloadError
|
rescue DownloadError
|
||||||
raise unless fallback_on_error
|
raise unless fallback_on_error?
|
||||||
|
|
||||||
fetch_tab
|
fetch_tab
|
||||||
retry
|
retry
|
||||||
@ -121,7 +121,7 @@ class Bottle
|
|||||||
begin
|
begin
|
||||||
resource.fetch(timeout:, quiet:)
|
resource.fetch(timeout:, quiet:)
|
||||||
rescue DownloadError
|
rescue DownloadError
|
||||||
raise unless fallback_on_error
|
raise unless fallback_on_error?
|
||||||
|
|
||||||
retry
|
retry
|
||||||
rescue Resource::BottleManifest::Error
|
rescue Resource::BottleManifest::Error
|
||||||
@ -193,7 +193,7 @@ class Bottle
|
|||||||
specs
|
specs
|
||||||
end
|
end
|
||||||
|
|
||||||
def fallback_on_error
|
def fallback_on_error?
|
||||||
# Use the default bottle domain as a fallback mirror
|
# Use the default bottle domain as a fallback mirror
|
||||||
if @resource.url.start_with?(Homebrew::EnvConfig.bottle_domain) &&
|
if @resource.url.start_with?(Homebrew::EnvConfig.bottle_domain) &&
|
||||||
Homebrew::EnvConfig.bottle_domain != HOMEBREW_BOTTLE_DEFAULT_DOMAIN
|
Homebrew::EnvConfig.bottle_domain != HOMEBREW_BOTTLE_DEFAULT_DOMAIN
|
||||||
|
|||||||
@ -41,7 +41,7 @@ module Homebrew
|
|||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def mas_installed?
|
def mas_installed?
|
||||||
@mas_installed ||= which_formula("mas")
|
@mas_installed ||= which_formula?("mas")
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
@ -59,7 +59,7 @@ module Homebrew
|
|||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def whalebrew_installed?
|
def whalebrew_installed?
|
||||||
@whalebrew_installed ||= which_formula("whalebrew")
|
@whalebrew_installed ||= which_formula?("whalebrew")
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
@ -70,7 +70,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { params(name: String).returns(T::Boolean) }
|
sig { params(name: String).returns(T::Boolean) }
|
||||||
def which_formula(name)
|
def which_formula?(name)
|
||||||
formula = Formulary.factory(name)
|
formula = Formulary.factory(name)
|
||||||
ENV["PATH"] = "#{formula.opt_bin}:#{ENV.fetch("PATH", nil)}" if formula.any_version_installed?
|
ENV["PATH"] = "#{formula.opt_bin}:#{ENV.fetch("PATH", nil)}" if formula.any_version_installed?
|
||||||
which(name).present?
|
which(name).present?
|
||||||
|
|||||||
@ -18,7 +18,7 @@ module Homebrew
|
|||||||
Homebrew::Bundle::CaskDumper.cask_is_outdated_using_greedy?(name)
|
Homebrew::Bundle::CaskDumper.cask_is_outdated_using_greedy?(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.preinstall(name, no_upgrade: false, verbose: false, **options)
|
def self.preinstall!(name, no_upgrade: false, verbose: false, **options)
|
||||||
if installed_casks.include?(name) && !upgrading?(no_upgrade, name, options)
|
if installed_casks.include?(name) && !upgrading?(no_upgrade, name, options)
|
||||||
puts "Skipping install of #{name} cask. It is already installed." if verbose
|
puts "Skipping install of #{name} cask. It is already installed." if verbose
|
||||||
return false
|
return false
|
||||||
@ -27,7 +27,7 @@ module Homebrew
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.install(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
||||||
return true unless preinstall
|
return true unless preinstall
|
||||||
|
|
||||||
full_name = options.fetch(:full_name, name)
|
full_name = options.fetch(:full_name, name)
|
||||||
|
|||||||
@ -37,12 +37,12 @@ module Homebrew
|
|||||||
if casks.any?
|
if casks.any?
|
||||||
args = zap ? ["--zap"] : []
|
args = zap ? ["--zap"] : []
|
||||||
Kernel.system HOMEBREW_BREW_FILE, "uninstall", "--cask", *args, "--force", *casks
|
Kernel.system HOMEBREW_BREW_FILE, "uninstall", "--cask", *args, "--force", *casks
|
||||||
puts "Uninstalled #{casks.size} cask#{(casks.size == 1) ? "" : "s"}"
|
puts "Uninstalled #{casks.size} cask#{"s" if casks.size != 1}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if formulae.any?
|
if formulae.any?
|
||||||
Kernel.system HOMEBREW_BREW_FILE, "uninstall", "--formula", "--force", *formulae
|
Kernel.system HOMEBREW_BREW_FILE, "uninstall", "--formula", "--force", *formulae
|
||||||
puts "Uninstalled #{formulae.size} formula#{(formulae.size == 1) ? "" : "e"}"
|
puts "Uninstalled #{formulae.size} formula#{"e" if formulae.size != 1}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Kernel.system HOMEBREW_BREW_FILE, "untap", *taps if taps.any?
|
Kernel.system HOMEBREW_BREW_FILE, "untap", *taps if taps.any?
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Homebrew
|
|||||||
def self.run(global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false,
|
def self.run(global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false,
|
||||||
quiet: false)
|
quiet: false)
|
||||||
@dsl = Brewfile.read(global:, file:)
|
@dsl = Brewfile.read(global:, file:)
|
||||||
Homebrew::Bundle::Installer.install(
|
Homebrew::Bundle::Installer.install!(
|
||||||
@dsl.entries,
|
@dsl.entries,
|
||||||
global:, file:, no_lock:, no_upgrade:, verbose:, force:, quiet:,
|
global:, file:, no_lock:, no_upgrade:, verbose:, force:, quiet:,
|
||||||
) || exit(1)
|
) || exit(1)
|
||||||
|
|||||||
@ -10,12 +10,12 @@ module Homebrew
|
|||||||
@pinned_formulae = nil
|
@pinned_formulae = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.preinstall(name, no_upgrade: false, verbose: false, **options)
|
def self.preinstall!(name, no_upgrade: false, verbose: false, **options)
|
||||||
new(name, options).preinstall(no_upgrade:, verbose:)
|
new(name, options).preinstall!(no_upgrade:, verbose:)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.install(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
||||||
new(name, options).install(preinstall:, no_upgrade:, verbose:, force:)
|
new(name, options).install!(preinstall:, no_upgrade:, verbose:, force:)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(name, options = {})
|
def initialize(name, options = {})
|
||||||
@ -31,7 +31,7 @@ module Homebrew
|
|||||||
@changed = nil
|
@changed = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def preinstall(no_upgrade: false, verbose: false)
|
def preinstall!(no_upgrade: false, verbose: false)
|
||||||
if installed? && (self.class.no_upgrade_with_args?(no_upgrade, @name) || !upgradable?)
|
if installed? && (self.class.no_upgrade_with_args?(no_upgrade, @name) || !upgradable?)
|
||||||
puts "Skipping install of #{@name} formula. It is already installed." if verbose
|
puts "Skipping install of #{@name} formula. It is already installed." if verbose
|
||||||
@changed = nil
|
@changed = nil
|
||||||
@ -41,7 +41,7 @@ module Homebrew
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def install(preinstall: true, no_upgrade: false, verbose: false, force: false)
|
def install!(preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||||
install_result = if preinstall
|
install_result = if preinstall
|
||||||
install_change_state!(no_upgrade:, verbose:, force:)
|
install_change_state!(no_upgrade:, verbose:, force:)
|
||||||
else
|
else
|
||||||
@ -80,9 +80,9 @@ module Homebrew
|
|||||||
return false unless resolve_conflicts!(verbose:)
|
return false unless resolve_conflicts!(verbose:)
|
||||||
|
|
||||||
if installed?
|
if installed?
|
||||||
upgrade!(verbose:, force:)
|
upgrade_formula!(verbose:, force:)
|
||||||
else
|
else
|
||||||
install!(verbose:, force:)
|
install_formula!(verbose:, force:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ module Homebrew
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def install!(verbose:, force:)
|
def install_formula!(verbose:, force:)
|
||||||
install_args = @args.dup
|
install_args = @args.dup
|
||||||
install_args << "--force" << "--overwrite" if force
|
install_args << "--force" << "--overwrite" if force
|
||||||
install_args << "--skip-link" if @link == false
|
install_args << "--skip-link" if @link == false
|
||||||
@ -298,7 +298,7 @@ module Homebrew
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def upgrade!(verbose:, force:)
|
def upgrade_formula!(verbose:, force:)
|
||||||
upgrade_args = []
|
upgrade_args = []
|
||||||
upgrade_args << "--force" if force
|
upgrade_args << "--force" if force
|
||||||
with_args = " with #{upgrade_args.join(" ")}" if upgrade_args.present?
|
with_args = " with #{upgrade_args.join(" ")}" if upgrade_args.present?
|
||||||
|
|||||||
@ -13,8 +13,8 @@ require "bundle/skipper"
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
module Bundle
|
module Bundle
|
||||||
module Installer
|
module Installer
|
||||||
def self.install(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false,
|
def self.install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false,
|
||||||
force: false, quiet: false)
|
force: false, quiet: false)
|
||||||
success = 0
|
success = 0
|
||||||
failure = 0
|
failure = 0
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ module Homebrew
|
|||||||
next if cls.nil?
|
next if cls.nil?
|
||||||
next if Homebrew::Bundle::Skipper.skip? entry
|
next if Homebrew::Bundle::Skipper.skip? entry
|
||||||
|
|
||||||
preinstall = if cls.preinstall(*args, **options, no_upgrade:, verbose:)
|
preinstall = if cls.preinstall!(*args, **options, no_upgrade:, verbose:)
|
||||||
puts Formatter.success("#{verb} #{name}")
|
puts Formatter.success("#{verb} #{name}")
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
@ -57,7 +57,7 @@ module Homebrew
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
if cls.install(*args, **options,
|
if cls.install!(*args, **options,
|
||||||
preinstall:, no_upgrade:, verbose:, force:)
|
preinstall:, no_upgrade:, verbose:, force:)
|
||||||
success += 1
|
success += 1
|
||||||
else
|
else
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Homebrew
|
|||||||
@outdated_app_ids = nil
|
@outdated_app_ids = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.preinstall(name, id, no_upgrade: false, verbose: false)
|
def self.preinstall!(name, id, no_upgrade: false, verbose: false)
|
||||||
unless Bundle.mas_installed?
|
unless Bundle.mas_installed?
|
||||||
puts "Installing mas. It is not currently installed." if verbose
|
puts "Installing mas. It is not currently installed." if verbose
|
||||||
Bundle.brew("install", "mas", verbose:)
|
Bundle.brew("install", "mas", verbose:)
|
||||||
@ -27,7 +27,7 @@ module Homebrew
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.install(name, id, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
def self.install!(name, id, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||||
return true unless preinstall
|
return true unless preinstall
|
||||||
|
|
||||||
if app_id_installed?(id)
|
if app_id_installed?(id)
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
module Bundle
|
module Bundle
|
||||||
module TapInstaller
|
module TapInstaller
|
||||||
def self.preinstall(name, verbose: false, **_options)
|
def self.preinstall!(name, verbose: false, **_options)
|
||||||
if installed_taps.include? name
|
if installed_taps.include? name
|
||||||
puts "Skipping install of #{name} tap. It is already installed." if verbose
|
puts "Skipping install of #{name} tap. It is already installed." if verbose
|
||||||
return false
|
return false
|
||||||
@ -13,7 +13,7 @@ module Homebrew
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.install(name, preinstall: true, verbose: false, force: false, **options)
|
def self.install!(name, preinstall: true, verbose: false, force: false, **options)
|
||||||
return true unless preinstall
|
return true unless preinstall
|
||||||
|
|
||||||
puts "Installing #{name} tap. It is not currently installed." if verbose
|
puts "Installing #{name} tap. It is not currently installed." if verbose
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module Homebrew
|
|||||||
@installed_extensions = nil
|
@installed_extensions = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.preinstall(name, no_upgrade: false, verbose: false)
|
def self.preinstall!(name, no_upgrade: false, verbose: false)
|
||||||
if !Bundle.vscode_installed? && Bundle.cask_installed?
|
if !Bundle.vscode_installed? && Bundle.cask_installed?
|
||||||
puts "Installing visual-studio-code. It is not currently installed." if verbose
|
puts "Installing visual-studio-code. It is not currently installed." if verbose
|
||||||
Bundle.brew("install", "--cask", "visual-studio-code", verbose:)
|
Bundle.brew("install", "--cask", "visual-studio-code", verbose:)
|
||||||
@ -24,7 +24,7 @@ module Homebrew
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.install(name, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||||
return true unless preinstall
|
return true unless preinstall
|
||||||
return true if extension_installed?(name)
|
return true if extension_installed?(name)
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module Homebrew
|
|||||||
@installed_images = nil
|
@installed_images = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.preinstall(name, verbose: false, **_options)
|
def self.preinstall!(name, verbose: false, **_options)
|
||||||
unless Bundle.whalebrew_installed?
|
unless Bundle.whalebrew_installed?
|
||||||
puts "Installing whalebrew. It is not currently installed." if verbose
|
puts "Installing whalebrew. It is not currently installed." if verbose
|
||||||
Bundle.brew("install", "--formula", "whalebrew", verbose:)
|
Bundle.brew("install", "--formula", "whalebrew", verbose:)
|
||||||
@ -23,7 +23,7 @@ module Homebrew
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.install(name, preinstall: true, verbose: false, force: false, **_options)
|
def self.install!(name, preinstall: true, verbose: false, force: false, **_options)
|
||||||
odeprecated "`brew bundle` `whalebrew` support", "using `whalebrew` directly"
|
odeprecated "`brew bundle` `whalebrew` support", "using `whalebrew` directly"
|
||||||
return true unless preinstall
|
return true unless preinstall
|
||||||
|
|
||||||
|
|||||||
@ -189,7 +189,7 @@ on_request: true)
|
|||||||
when :deprecated
|
when :deprecated
|
||||||
opoo message_full
|
opoo message_full
|
||||||
when :disabled
|
when :disabled
|
||||||
GitHub::Actions.puts_annotation_if_env_set(:error, message)
|
GitHub::Actions.puts_annotation_if_env_set!(:error, message)
|
||||||
raise CaskCannotBeInstalledError.new(@cask, message)
|
raise CaskCannotBeInstalledError.new(@cask, message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,7 +23,7 @@ module Cask
|
|||||||
require_sha: T.nilable(T::Boolean),
|
require_sha: T.nilable(T::Boolean),
|
||||||
).returns(T::Boolean)
|
).returns(T::Boolean)
|
||||||
}
|
}
|
||||||
def self.upgrade_casks(
|
def self.upgrade_casks!(
|
||||||
*casks,
|
*casks,
|
||||||
args:,
|
args:,
|
||||||
force: false,
|
force: false,
|
||||||
@ -134,7 +134,7 @@ module Cask
|
|||||||
|
|
||||||
return true if caught_exceptions.empty?
|
return true if caught_exceptions.empty?
|
||||||
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1
|
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1
|
||||||
raise caught_exceptions.fetch(0) if caught_exceptions.count == 1
|
raise caught_exceptions.fetch(0) if caught_exceptions.one?
|
||||||
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|||||||
@ -194,7 +194,7 @@ class Caveats
|
|||||||
startup = formula.service.requires_root?
|
startup = formula.service.requires_root?
|
||||||
if Utils::Service.running?(formula)
|
if Utils::Service.running?(formula)
|
||||||
s << "To restart #{formula.full_name} after an upgrade:"
|
s << "To restart #{formula.full_name} after an upgrade:"
|
||||||
s << " #{startup ? "sudo " : ""}brew services restart #{formula.full_name}"
|
s << " #{"sudo " if startup}brew services restart #{formula.full_name}"
|
||||||
elsif startup
|
elsif startup
|
||||||
s << "To start #{formula.full_name} now and restart at startup:"
|
s << "To start #{formula.full_name} now and restart at startup:"
|
||||||
s << " sudo brew services start #{formula.full_name}"
|
s << " sudo brew services start #{formula.full_name}"
|
||||||
|
|||||||
@ -259,7 +259,7 @@ module Homebrew
|
|||||||
if !Homebrew::EnvConfig.no_install_upgrade? && installed_casks.any?
|
if !Homebrew::EnvConfig.no_install_upgrade? && installed_casks.any?
|
||||||
require "cask/upgrade"
|
require "cask/upgrade"
|
||||||
|
|
||||||
Cask::Upgrade.upgrade_casks(
|
Cask::Upgrade.upgrade_casks!(
|
||||||
*installed_casks,
|
*installed_casks,
|
||||||
force: args.force?,
|
force: args.force?,
|
||||||
dry_run: args.dry_run?,
|
dry_run: args.dry_run?,
|
||||||
|
|||||||
@ -52,8 +52,8 @@ module Homebrew
|
|||||||
|
|
||||||
version = Keg.new(path).version
|
version = Keg.new(path).version
|
||||||
major_version = version.major.to_i
|
major_version = version.major.to_i
|
||||||
minor_version = version.minor.to_i || 0
|
minor_version = version.minor.to_i
|
||||||
patch_version = version.patch.to_i || 0
|
patch_version = version.patch.to_i
|
||||||
|
|
||||||
minor_version_range, patch_version_range = if Homebrew::EnvConfig.env_sync_strict?
|
minor_version_range, patch_version_range = if Homebrew::EnvConfig.env_sync_strict?
|
||||||
# Only create symlinks for the exact installed patch version.
|
# Only create symlinks for the exact installed patch version.
|
||||||
|
|||||||
@ -53,7 +53,7 @@ module Homebrew
|
|||||||
version = Keg.new(path).version
|
version = Keg.new(path).version
|
||||||
major_version = version.major.to_i
|
major_version = version.major.to_i
|
||||||
minor_version = version.minor.to_i
|
minor_version = version.minor.to_i
|
||||||
patch_version = version.patch.to_i || 0
|
patch_version = version.patch.to_i
|
||||||
|
|
||||||
patch_version_range = if Homebrew::EnvConfig.env_sync_strict?
|
patch_version_range = if Homebrew::EnvConfig.env_sync_strict?
|
||||||
# Only create symlinks for the exact installed patch version.
|
# Only create symlinks for the exact installed patch version.
|
||||||
|
|||||||
@ -65,7 +65,7 @@ module Homebrew
|
|||||||
|
|
||||||
sig { override.void }
|
sig { override.void }
|
||||||
def run
|
def run
|
||||||
return if search_package_manager
|
return if search_package_manager!
|
||||||
|
|
||||||
query = args.named.join(" ")
|
query = args.named.join(" ")
|
||||||
string_or_regex = Search.query_regexp(query)
|
string_or_regex = Search.query_regexp(query)
|
||||||
@ -108,7 +108,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def search_package_manager
|
def search_package_manager!
|
||||||
package_manager = PACKAGE_MANAGERS.find { |name,| args.public_send(:"#{name}?") }
|
package_manager = PACKAGE_MANAGERS.find { |name,| args.public_send(:"#{name}?") }
|
||||||
return false if package_manager.nil?
|
return false if package_manager.nil?
|
||||||
|
|
||||||
|
|||||||
@ -137,8 +137,8 @@ module Homebrew
|
|||||||
|
|
||||||
formulae = Homebrew::Attestation.sort_formulae_for_install(formulae) if Homebrew::Attestation.enabled?
|
formulae = Homebrew::Attestation.sort_formulae_for_install(formulae) if Homebrew::Attestation.enabled?
|
||||||
|
|
||||||
upgrade_outdated_formulae(formulae) unless only_upgrade_casks
|
upgrade_outdated_formulae!(formulae) unless only_upgrade_casks
|
||||||
upgrade_outdated_casks(casks) unless only_upgrade_formulae
|
upgrade_outdated_casks!(casks) unless only_upgrade_formulae
|
||||||
|
|
||||||
Cleanup.periodic_clean!(dry_run: args.dry_run?)
|
Cleanup.periodic_clean!(dry_run: args.dry_run?)
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ module Homebrew
|
|||||||
private
|
private
|
||||||
|
|
||||||
sig { params(formulae: T::Array[Formula]).returns(T::Boolean) }
|
sig { params(formulae: T::Array[Formula]).returns(T::Boolean) }
|
||||||
def upgrade_outdated_formulae(formulae)
|
def upgrade_outdated_formulae!(formulae)
|
||||||
return false if args.cask?
|
return false if args.cask?
|
||||||
|
|
||||||
if args.build_from_source?
|
if args.build_from_source?
|
||||||
@ -280,12 +280,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { params(casks: T::Array[Cask::Cask]).returns(T::Boolean) }
|
sig { params(casks: T::Array[Cask::Cask]).returns(T::Boolean) }
|
||||||
def upgrade_outdated_casks(casks)
|
def upgrade_outdated_casks!(casks)
|
||||||
return false if args.formula?
|
return false if args.formula?
|
||||||
|
|
||||||
Install.ask_casks casks if args.ask?
|
Install.ask_casks casks if args.ask?
|
||||||
|
|
||||||
Cask::Upgrade.upgrade_casks(
|
Cask::Upgrade.upgrade_casks!(
|
||||||
*casks,
|
*casks,
|
||||||
force: args.force?,
|
force: args.force?,
|
||||||
greedy: args.greedy?,
|
greedy: args.greedy?,
|
||||||
|
|||||||
@ -723,7 +723,7 @@ module Homebrew
|
|||||||
all_bottle = !args.no_all_checks? &&
|
all_bottle = !args.no_all_checks? &&
|
||||||
(!old_bottle_spec_matches || bottle.rebuild != old_bottle_spec.rebuild) &&
|
(!old_bottle_spec_matches || bottle.rebuild != old_bottle_spec.rebuild) &&
|
||||||
tag_hashes.count > 1 &&
|
tag_hashes.count > 1 &&
|
||||||
tag_hashes.uniq { |tag_hash| "#{tag_hash["cellar"]}-#{tag_hash["sha256"]}" }.count == 1
|
tag_hashes.uniq { |tag_hash| "#{tag_hash["cellar"]}-#{tag_hash["sha256"]}" }.one?
|
||||||
|
|
||||||
old_all_bottle = old_bottle_spec.tag?(Utils::Bottles.tag(:all))
|
old_all_bottle = old_bottle_spec.tag?(Utils::Bottles.tag(:all))
|
||||||
if !all_bottle && old_all_bottle && !args.no_all_checks?
|
if !all_bottle && old_all_bottle && !args.no_all_checks?
|
||||||
|
|||||||
@ -589,7 +589,7 @@ module Homebrew
|
|||||||
#{leading_spaces}resource "#{resource.name}" do
|
#{leading_spaces}resource "#{resource.name}" do
|
||||||
#{leading_spaces} url "#{new_url}"#{new_mirrors.map { |m| "\n#{leading_spaces} mirror \"#{m}\"" }.join}
|
#{leading_spaces} url "#{new_url}"#{new_mirrors.map { |m| "\n#{leading_spaces} mirror \"#{m}\"" }.join}
|
||||||
#{leading_spaces} sha256 "#{new_hash}"
|
#{leading_spaces} sha256 "#{new_hash}"
|
||||||
#{forced_version ? "#{leading_spaces} version \"#{version}\"\n" : ""}
|
#{"#{leading_spaces} version \"#{version}\"\n" if forced_version}
|
||||||
#{leading_spaces} livecheck do
|
#{leading_spaces} livecheck do
|
||||||
#{leading_spaces} formula :parent
|
#{leading_spaces} formula :parent
|
||||||
#{leading_spaces} end
|
#{leading_spaces} end
|
||||||
|
|||||||
@ -180,7 +180,7 @@ module Homebrew
|
|||||||
|
|
||||||
formulae_and_casks.each_with_index do |formula_or_cask, i|
|
formulae_and_casks.each_with_index do |formula_or_cask, i|
|
||||||
puts if i.positive?
|
puts if i.positive?
|
||||||
next if skip_ineligible_formulae(formula_or_cask)
|
next if skip_ineligible_formulae!(formula_or_cask)
|
||||||
|
|
||||||
use_full_name = args.full_name? || ambiguous_names.include?(formula_or_cask)
|
use_full_name = args.full_name? || ambiguous_names.include?(formula_or_cask)
|
||||||
name = Livecheck.package_or_resource_name(formula_or_cask, full_name: use_full_name)
|
name = Livecheck.package_or_resource_name(formula_or_cask, full_name: use_full_name)
|
||||||
@ -204,7 +204,7 @@ module Homebrew
|
|||||||
sig {
|
sig {
|
||||||
params(formula_or_cask: T.any(Formula, Cask::Cask)).returns(T::Boolean)
|
params(formula_or_cask: T.any(Formula, Cask::Cask)).returns(T::Boolean)
|
||||||
}
|
}
|
||||||
def skip_ineligible_formulae(formula_or_cask)
|
def skip_ineligible_formulae!(formula_or_cask)
|
||||||
if formula_or_cask.is_a?(Formula)
|
if formula_or_cask.is_a?(Formula)
|
||||||
skip = formula_or_cask.disabled? || formula_or_cask.head_only?
|
skip = formula_or_cask.disabled? || formula_or_cask.head_only?
|
||||||
name = formula_or_cask.name
|
name = formula_or_cask.name
|
||||||
|
|||||||
@ -587,7 +587,7 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def __check_linked_brew(formula)
|
def __check_linked_brew!(formula)
|
||||||
formula.installed_prefixes.each do |prefix|
|
formula.installed_prefixes.each do |prefix|
|
||||||
prefix.find do |src|
|
prefix.find do |src|
|
||||||
next if src == prefix
|
next if src == prefix
|
||||||
|
|||||||
@ -341,7 +341,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
|
|||||||
.reject { |path| path.extname.end_with?(".incomplete") }
|
.reject { |path| path.extname.end_with?(".incomplete") }
|
||||||
|
|
||||||
@cached_location = T.let(
|
@cached_location = T.let(
|
||||||
if downloads.count == 1
|
if downloads.one?
|
||||||
downloads.fetch(0)
|
downloads.fetch(0)
|
||||||
else
|
else
|
||||||
HOMEBREW_CACHE/"downloads/#{url_sha256}--#{Utils.safe_filename(resolved_basename)}"
|
HOMEBREW_CACHE/"downloads/#{url_sha256}--#{Utils.safe_filename(resolved_basename)}"
|
||||||
|
|||||||
@ -20,11 +20,11 @@ class File
|
|||||||
# file.write('hello')
|
# file.write('hello')
|
||||||
# end
|
# end
|
||||||
sig {
|
sig {
|
||||||
type_parameters(:out).params(
|
type_parameters(:Out).params(
|
||||||
file_name: T.any(Pathname, String),
|
file_name: T.any(Pathname, String),
|
||||||
temp_dir: String,
|
temp_dir: String,
|
||||||
_block: T.proc.params(arg0: Tempfile).returns(T.type_parameter(:out)),
|
_block: T.proc.params(arg0: Tempfile).returns(T.type_parameter(:Out)),
|
||||||
).returns(T.type_parameter(:out))
|
).returns(T.type_parameter(:Out))
|
||||||
}
|
}
|
||||||
def self.atomic_write(file_name, temp_dir = dirname(file_name), &_block)
|
def self.atomic_write(file_name, temp_dir = dirname(file_name), &_block)
|
||||||
require "tempfile" unless defined?(Tempfile)
|
require "tempfile" unless defined?(Tempfile)
|
||||||
|
|||||||
@ -3,18 +3,18 @@
|
|||||||
|
|
||||||
class Hash
|
class Hash
|
||||||
sig {
|
sig {
|
||||||
type_parameters(:k2).params(
|
type_parameters(:K2).params(
|
||||||
other_hash: T::Hash[T.type_parameter(:k2), T.untyped],
|
other_hash: T::Hash[T.type_parameter(:K2), T.untyped],
|
||||||
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
|
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
|
||||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped])
|
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:K2)), T.untyped])
|
||||||
}
|
}
|
||||||
def deep_merge(other_hash, &block); end
|
def deep_merge(other_hash, &block); end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
type_parameters(:k2).params(
|
type_parameters(:K2).params(
|
||||||
other_hash: T::Hash[T.type_parameter(:k2), T.untyped],
|
other_hash: T::Hash[T.type_parameter(:K2), T.untyped],
|
||||||
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
|
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
|
||||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped])
|
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:K2)), T.untyped])
|
||||||
}
|
}
|
||||||
def deep_merge!(other_hash, &block); end
|
def deep_merge!(other_hash, &block); end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
class Hash
|
class Hash
|
||||||
sig {
|
sig {
|
||||||
type_parameters(:out).params(
|
type_parameters(:Out).params(
|
||||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)),
|
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:Out)),
|
||||||
).returns(T::Hash[Hash::K, T.type_parameter(:out)])
|
).returns(T::Hash[Hash::K, T.type_parameter(:Out)])
|
||||||
}
|
}
|
||||||
def deep_transform_values(&block); end
|
def deep_transform_values(&block); end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
type_parameters(:out).params(
|
type_parameters(:Out).params(
|
||||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)),
|
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:Out)),
|
||||||
).returns(T::Hash[Hash::K, T.type_parameter(:out)])
|
).returns(T::Hash[Hash::K, T.type_parameter(:Out)])
|
||||||
}
|
}
|
||||||
def deep_transform_values!(&block); end
|
def deep_transform_values!(&block); end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,16 +3,16 @@
|
|||||||
|
|
||||||
class Hash
|
class Hash
|
||||||
sig {
|
sig {
|
||||||
type_parameters(:out).params(
|
type_parameters(:Out).params(
|
||||||
block: T.proc.params(o: K).returns(T.type_parameter(:out)),
|
block: T.proc.params(o: K).returns(T.type_parameter(:Out)),
|
||||||
).returns(T::Hash[T.type_parameter(:out), V])
|
).returns(T::Hash[T.type_parameter(:Out), V])
|
||||||
}
|
}
|
||||||
def deep_transform_keys(&block); end
|
def deep_transform_keys(&block); end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
type_parameters(:out).params(
|
type_parameters(:Out).params(
|
||||||
block: T.proc.params(o: K).returns(T.type_parameter(:out)),
|
block: T.proc.params(o: K).returns(T.type_parameter(:Out)),
|
||||||
).returns(T::Hash[T.type_parameter(:out), V])
|
).returns(T::Hash[T.type_parameter(:Out), V])
|
||||||
}
|
}
|
||||||
def deep_transform_keys!(&block); end
|
def deep_transform_keys!(&block); end
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,7 @@ module Kernel
|
|||||||
sig { params(message: T.any(String, Exception)).void }
|
sig { params(message: T.any(String, Exception)).void }
|
||||||
def opoo(message)
|
def opoo(message)
|
||||||
require "utils/github/actions"
|
require "utils/github/actions"
|
||||||
return if GitHub::Actions.puts_annotation_if_env_set(:warning, message.to_s)
|
return if GitHub::Actions.puts_annotation_if_env_set!(:warning, message.to_s)
|
||||||
|
|
||||||
require "utils/formatter"
|
require "utils/formatter"
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ module Kernel
|
|||||||
sig { params(message: T.any(String, Exception)).void }
|
sig { params(message: T.any(String, Exception)).void }
|
||||||
def onoe(message)
|
def onoe(message)
|
||||||
require "utils/github/actions"
|
require "utils/github/actions"
|
||||||
return if GitHub::Actions.puts_annotation_if_env_set(:error, message.to_s)
|
return if GitHub::Actions.puts_annotation_if_env_set!(:error, message.to_s)
|
||||||
|
|
||||||
require "utils/formatter"
|
require "utils/formatter"
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ module Kernel
|
|||||||
disable = true if disable_for_developers && Homebrew::EnvConfig.developer?
|
disable = true if disable_for_developers && Homebrew::EnvConfig.developer?
|
||||||
if disable || Homebrew.raise_deprecation_exceptions?
|
if disable || Homebrew.raise_deprecation_exceptions?
|
||||||
require "utils/github/actions"
|
require "utils/github/actions"
|
||||||
GitHub::Actions.puts_annotation_if_env_set(:error, message, file:, line:)
|
GitHub::Actions.puts_annotation_if_env_set!(:error, message, file:, line:)
|
||||||
exception = MethodDeprecatedError.new(message)
|
exception = MethodDeprecatedError.new(message)
|
||||||
exception.set_backtrace(backtrace)
|
exception.set_backtrace(backtrace)
|
||||||
raise exception
|
raise exception
|
||||||
|
|||||||
@ -12,12 +12,12 @@ class Keg
|
|||||||
|
|
||||||
elf_files.each do |file|
|
elf_files.each do |file|
|
||||||
file.ensure_writable do
|
file.ensure_writable do
|
||||||
change_rpath(file, old_prefix, new_prefix)
|
change_rpath!(file, old_prefix, new_prefix)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_rpath(file, old_prefix, new_prefix)
|
def change_rpath!(file, old_prefix, new_prefix)
|
||||||
return false if !file.elf? || !file.dynamic_elf?
|
return false if !file.elf? || !file.dynamic_elf?
|
||||||
|
|
||||||
updated = {}
|
updated = {}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ require "requirement"
|
|||||||
|
|
||||||
class XcodeRequirement < Requirement
|
class XcodeRequirement < Requirement
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def xcode_installed_version
|
def xcode_installed_version!
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -38,7 +38,7 @@ module OS
|
|||||||
# conflict between what `uname` reports and the underlying `sysctl` flags,
|
# conflict between what `uname` reports and the underlying `sysctl` flags,
|
||||||
# since the `sysctl` flags don't change behaviour under Rosetta 2.
|
# since the `sysctl` flags don't change behaviour under Rosetta 2.
|
||||||
def in_rosetta2?
|
def in_rosetta2?
|
||||||
::Hardware::CPU.sysctl_bool("sysctl.proc_translated")
|
::Hardware::CPU.sysctl_bool!("sysctl.proc_translated")
|
||||||
end
|
end
|
||||||
|
|
||||||
def features
|
def features
|
||||||
@ -50,7 +50,7 @@ module OS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sse4?
|
def sse4?
|
||||||
::Hardware::CPU.sysctl_bool("hw.optional.sse4_1")
|
::Hardware::CPU.sysctl_bool!("hw.optional.sse4_1")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -68,41 +68,41 @@ module Hardware
|
|||||||
end
|
end
|
||||||
|
|
||||||
def aes?
|
def aes?
|
||||||
sysctl_bool("hw.optional.aes")
|
sysctl_bool!("hw.optional.aes")
|
||||||
end
|
end
|
||||||
|
|
||||||
def altivec?
|
def altivec?
|
||||||
sysctl_bool("hw.optional.altivec")
|
sysctl_bool!("hw.optional.altivec")
|
||||||
end
|
end
|
||||||
|
|
||||||
def avx?
|
def avx?
|
||||||
sysctl_bool("hw.optional.avx1_0")
|
sysctl_bool!("hw.optional.avx1_0")
|
||||||
end
|
end
|
||||||
|
|
||||||
def avx2?
|
def avx2?
|
||||||
sysctl_bool("hw.optional.avx2_0")
|
sysctl_bool!("hw.optional.avx2_0")
|
||||||
end
|
end
|
||||||
|
|
||||||
def sse3?
|
def sse3?
|
||||||
sysctl_bool("hw.optional.sse3")
|
sysctl_bool!("hw.optional.sse3")
|
||||||
end
|
end
|
||||||
|
|
||||||
def ssse3?
|
def ssse3?
|
||||||
sysctl_bool("hw.optional.supplementalsse3")
|
sysctl_bool!("hw.optional.supplementalsse3")
|
||||||
end
|
end
|
||||||
|
|
||||||
def sse4_2?
|
def sse4_2?
|
||||||
sysctl_bool("hw.optional.sse4_2")
|
sysctl_bool!("hw.optional.sse4_2")
|
||||||
end
|
end
|
||||||
|
|
||||||
# NOTE: This is more reliable than checking `uname`. `sysctl` returns
|
# NOTE: This is more reliable than checking `uname`. `sysctl` returns
|
||||||
# the right answer even when running in Rosetta 2.
|
# the right answer even when running in Rosetta 2.
|
||||||
def physical_cpu_arm64?
|
def physical_cpu_arm64?
|
||||||
sysctl_bool("hw.optional.arm64")
|
sysctl_bool!("hw.optional.arm64")
|
||||||
end
|
end
|
||||||
|
|
||||||
def virtualized?
|
def virtualized?
|
||||||
sysctl_bool("kern.hv_vmm_present")
|
sysctl_bool!("kern.hv_vmm_present")
|
||||||
end
|
end
|
||||||
|
|
||||||
def arm_family
|
def arm_family
|
||||||
@ -173,7 +173,7 @@ module Hardware
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sysctl_bool(key)
|
def sysctl_bool!(key)
|
||||||
sysctl_int(key) == 1
|
sysctl_int(key) == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -306,7 +306,7 @@ class FormulaInstaller
|
|||||||
if force?
|
if force?
|
||||||
opoo message
|
opoo message
|
||||||
else
|
else
|
||||||
GitHub::Actions.puts_annotation_if_env_set(:error, message)
|
GitHub::Actions.puts_annotation_if_env_set!(:error, message)
|
||||||
raise CannotInstallFormulaError, message
|
raise CannotInstallFormulaError, message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -79,6 +79,9 @@ module Formulary
|
|||||||
end
|
end
|
||||||
|
|
||||||
module PathnameWriteMkpath
|
module PathnameWriteMkpath
|
||||||
|
# TODO: migrate away from refinements here, they don't play nicely with
|
||||||
|
# Sorbet, when we migrate to `typed: strict`
|
||||||
|
# rubocop:todo Sorbet/BlockMethodDefinition
|
||||||
refine Pathname do
|
refine Pathname do
|
||||||
def write(content, offset = nil, **open_args)
|
def write(content, offset = nil, **open_args)
|
||||||
T.bind(self, Pathname)
|
T.bind(self, Pathname)
|
||||||
@ -89,6 +92,7 @@ module Formulary
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Sorbet/BlockMethodDefinition
|
||||||
end
|
end
|
||||||
|
|
||||||
using PathnameWriteMkpath
|
using PathnameWriteMkpath
|
||||||
@ -133,7 +137,7 @@ module Formulary
|
|||||||
rescue NameError => e
|
rescue NameError => e
|
||||||
class_list = mod.constants
|
class_list = mod.constants
|
||||||
.map { |const_name| mod.const_get(const_name) }
|
.map { |const_name| mod.const_get(const_name) }
|
||||||
.select { |const| const.is_a?(Class) }
|
.grep(Class)
|
||||||
new_exception = FormulaClassUnavailableError.new(name, path, class_name, class_list)
|
new_exception = FormulaClassUnavailableError.new(name, path, class_name, class_list)
|
||||||
remove_const(namespace)
|
remove_const(namespace)
|
||||||
raise new_exception, "", e.backtrace
|
raise new_exception, "", e.backtrace
|
||||||
@ -170,7 +174,7 @@ module Formulary
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { params(name: String, flags: T::Array[String]).returns(T.class_of(Formula)) }
|
sig { params(name: String, flags: T::Array[String]).returns(T.class_of(Formula)) }
|
||||||
def self.load_formula_from_api(name, flags:)
|
def self.load_formula_from_api!(name, flags:)
|
||||||
namespace = :"FormulaNamespaceAPI#{namespace_key(name)}"
|
namespace = :"FormulaNamespaceAPI#{namespace_key(name)}"
|
||||||
|
|
||||||
mod = Module.new
|
mod = Module.new
|
||||||
@ -264,6 +268,9 @@ module Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: migrate away from this inline class here, they don't play nicely with
|
||||||
|
# Sorbet, when we migrate to `typed: strict`
|
||||||
|
# rubocop:todo Sorbet/BlockMethodDefinition
|
||||||
klass = Class.new(::Formula) do
|
klass = Class.new(::Formula) do
|
||||||
@loaded_from_api = true
|
@loaded_from_api = true
|
||||||
|
|
||||||
@ -431,6 +438,7 @@ module Formulary
|
|||||||
Checksum.new(checksum) if checksum
|
Checksum.new(checksum) if checksum
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Sorbet/BlockMethodDefinition
|
||||||
|
|
||||||
mod.const_set(class_name, klass)
|
mod.const_set(class_name, klass)
|
||||||
|
|
||||||
@ -902,7 +910,7 @@ module Formulary
|
|||||||
private
|
private
|
||||||
|
|
||||||
def load_from_api(flags:)
|
def load_from_api(flags:)
|
||||||
Formulary.load_formula_from_api(name, flags:)
|
Formulary.load_formula_from_api!(name, flags:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,9 @@ module Ignorable
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.hook_raise
|
def self.hook_raise
|
||||||
|
# TODO: migrate away from this inline class here, they don't play nicely with
|
||||||
|
# Sorbet, when we migrate to `typed: strict`
|
||||||
|
# rubocop:todo Sorbet/BlockMethodDefinition
|
||||||
Object.class_eval do
|
Object.class_eval do
|
||||||
alias_method :original_raise, :raise
|
alias_method :original_raise, :raise
|
||||||
|
|
||||||
@ -37,6 +40,7 @@ module Ignorable
|
|||||||
|
|
||||||
alias_method :fail, :raise
|
alias_method :fail, :raise
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Sorbet/BlockMethodDefinition
|
||||||
|
|
||||||
return unless block_given?
|
return unless block_given?
|
||||||
|
|
||||||
|
|||||||
@ -465,9 +465,7 @@ module Homebrew
|
|||||||
|
|
||||||
def collect_dependencies(formulae_installer, dependants)
|
def collect_dependencies(formulae_installer, dependants)
|
||||||
formulae_dependencies = formulae_installer.flat_map do |f|
|
formulae_dependencies = formulae_installer.flat_map do |f|
|
||||||
[f.formula, f.compute_dependencies.flatten.filter do |c|
|
[f.formula, f.compute_dependencies.flatten.grep(Dependency).flat_map(&:to_formula)]
|
||||||
c.is_a? Dependency
|
|
||||||
end.flat_map(&:to_formula)]
|
|
||||||
end.flatten.uniq
|
end.flatten.uniq
|
||||||
formulae_dependencies.concat(dependants.upgradeable) if dependants&.upgradeable
|
formulae_dependencies.concat(dependants.upgradeable) if dependants&.upgradeable
|
||||||
formulae_dependencies.uniq
|
formulae_dependencies.uniq
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class Keg
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { params(text: String).returns(T::Boolean) }
|
sig { params(text: String).returns(T::Boolean) }
|
||||||
def replace_text(text)
|
def replace_text!(text)
|
||||||
replacements = @replacement_map.values.to_h
|
replacements = @replacement_map.values.to_h
|
||||||
|
|
||||||
sorted_keys = replacements.keys.sort_by do |key|
|
sorted_keys = replacements.keys.sort_by do |key|
|
||||||
@ -143,7 +143,7 @@ class Keg
|
|||||||
files.map { path.join(_1) }.group_by { |f| f.stat.ino }.each_value do |first, *rest|
|
files.map { path.join(_1) }.group_by { |f| f.stat.ino }.each_value do |first, *rest|
|
||||||
s = first.open("rb", &:read)
|
s = first.open("rb", &:read)
|
||||||
|
|
||||||
next unless relocation.replace_text(s)
|
next unless relocation.replace_text!(s)
|
||||||
|
|
||||||
changed_files += [first, *rest].map { |file| file.relative_path_from(path) }
|
changed_files += [first, *rest].map { |file| file.relative_path_from(path) }
|
||||||
|
|
||||||
|
|||||||
@ -323,7 +323,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
return unless name
|
return unless name
|
||||||
|
|
||||||
if skip_hash[:messages].is_a?(Array) && skip_hash[:messages].count.positive?
|
if skip_hash[:messages].is_a?(Array) && skip_hash[:messages].any?
|
||||||
# TODO: Handle multiple messages, only if needed in the future
|
# TODO: Handle multiple messages, only if needed in the future
|
||||||
if skip_hash[:status] == "skipped"
|
if skip_hash[:status] == "skipped"
|
||||||
puts "#{Tty.red}#{name}#{Tty.reset}: skipped - #{skip_hash[:messages][0]}"
|
puts "#{Tty.red}#{name}#{Tty.reset}: skipped - #{skip_hash[:messages][0]}"
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class XcodeRequirement < Requirement
|
|||||||
|
|
||||||
satisfy(build_env: false) do
|
satisfy(build_env: false) do
|
||||||
T.bind(self, XcodeRequirement)
|
T.bind(self, XcodeRequirement)
|
||||||
xcode_installed_version
|
xcode_installed_version!
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(tags: T::Array[String]).void }
|
sig { params(tags: T::Array[String]).void }
|
||||||
@ -23,7 +23,7 @@ class XcodeRequirement < Requirement
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def xcode_installed_version
|
def xcode_installed_version!
|
||||||
return false unless MacOS::Xcode.installed?
|
return false unless MacOS::Xcode.installed?
|
||||||
return true unless @version
|
return true unless @version
|
||||||
|
|
||||||
|
|||||||
@ -228,13 +228,13 @@ module RuboCop
|
|||||||
rescue JSON::ParserError
|
rescue JSON::ParserError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
next if list_contents.nil? || list_contents.count.zero?
|
next if list_contents.nil? || list_contents.none?
|
||||||
|
|
||||||
@tap_style_exceptions[list_name] = list_contents
|
@tap_style_exceptions[list_name] = list_contents
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false if @tap_style_exceptions.nil? || @tap_style_exceptions.count.zero?
|
return false if @tap_style_exceptions.nil? || @tap_style_exceptions.none?
|
||||||
return false unless @tap_style_exceptions.key? list
|
return false unless @tap_style_exceptions.key? list
|
||||||
|
|
||||||
T.must(@tap_style_exceptions[list]).include?(formula || @formula_name)
|
T.must(@tap_style_exceptions[list]).include?(formula || @formula_name)
|
||||||
|
|||||||
@ -42,7 +42,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Check if formula has been found.
|
# Check if formula has been found.
|
||||||
def self.check(targets)
|
def self.check!(targets)
|
||||||
raise UsageError, "Formula(e) missing, please provide a formula name or use --all" if targets.empty?
|
raise UsageError, "Formula(e) missing, please provide a formula name or use --all" if targets.empty?
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|||||||
@ -17,7 +17,7 @@ module Homebrew
|
|||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
def self.run(targets, verbose:, json:)
|
def self.run(targets, verbose:, json:)
|
||||||
Services::Cli.check(targets)
|
Services::Cli.check!(targets)
|
||||||
|
|
||||||
output = targets.map(&:to_hash)
|
output = targets.map(&:to_hash)
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Homebrew
|
|||||||
|
|
||||||
sig { params(targets: T::Array[Services::FormulaWrapper], verbose: T::Boolean).void }
|
sig { params(targets: T::Array[Services::FormulaWrapper], verbose: T::Boolean).void }
|
||||||
def self.run(targets, verbose:)
|
def self.run(targets, verbose:)
|
||||||
Services::Cli.check(targets)
|
Services::Cli.check!(targets)
|
||||||
Services::Cli.kill(targets, verbose:)
|
Services::Cli.kill(targets, verbose:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -22,7 +22,7 @@ module Homebrew
|
|||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
def self.run(targets, custom_plist, verbose:)
|
def self.run(targets, custom_plist, verbose:)
|
||||||
Services::Cli.check(targets)
|
Services::Cli.check!(targets)
|
||||||
|
|
||||||
ran = []
|
ran = []
|
||||||
started = []
|
started = []
|
||||||
|
|||||||
@ -17,7 +17,7 @@ module Homebrew
|
|||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
def self.run(targets, custom_plist, verbose:)
|
def self.run(targets, custom_plist, verbose:)
|
||||||
Services::Cli.check(targets)
|
Services::Cli.check!(targets)
|
||||||
Services::Cli.run(targets, custom_plist, verbose:)
|
Services::Cli.run(targets, custom_plist, verbose:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -17,7 +17,7 @@ module Homebrew
|
|||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
def self.run(targets, custom_plist, verbose:)
|
def self.run(targets, custom_plist, verbose:)
|
||||||
Services::Cli.check(targets)
|
Services::Cli.check!(targets)
|
||||||
Services::Cli.start(targets, custom_plist, verbose:)
|
Services::Cli.start(targets, custom_plist, verbose:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -19,7 +19,7 @@ module Homebrew
|
|||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
def self.run(targets, verbose:, no_wait:, max_wait:, keep:)
|
def self.run(targets, verbose:, no_wait:, max_wait:, keep:)
|
||||||
Services::Cli.check(targets)
|
Services::Cli.check!(targets)
|
||||||
Services::Cli.stop(targets, verbose:, no_wait:, max_wait:, keep:)
|
Services::Cli.stop(targets, verbose:, no_wait:, max_wait:, keep:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -86,7 +86,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
shfmt_result = files.present? && shell_files.empty?
|
shfmt_result = files.present? && shell_files.empty?
|
||||||
shfmt_result ||= run_shfmt(shell_files, fix:)
|
shfmt_result ||= run_shfmt!(shell_files, fix:)
|
||||||
|
|
||||||
actionlint_files = github_workflow_files if files.blank? && actionlint_files.blank?
|
actionlint_files = github_workflow_files if files.blank? && actionlint_files.blank?
|
||||||
has_actionlint_workflow = actionlint_files.any? do |path|
|
has_actionlint_workflow = actionlint_files.any? do |path|
|
||||||
@ -94,7 +94,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
odebug "actionlint workflow detected. Skipping actionlint checks." if has_actionlint_workflow
|
odebug "actionlint workflow detected. Skipping actionlint checks." if has_actionlint_workflow
|
||||||
actionlint_result = files.present? && (has_actionlint_workflow || actionlint_files.empty?)
|
actionlint_result = files.present? && (has_actionlint_workflow || actionlint_files.empty?)
|
||||||
actionlint_result ||= run_actionlint(actionlint_files)
|
actionlint_result ||= run_actionlint!(actionlint_files)
|
||||||
|
|
||||||
if output_type == :json
|
if output_type == :json
|
||||||
Offenses.new(rubocop_result + shellcheck_result)
|
Offenses.new(rubocop_result + shellcheck_result)
|
||||||
@ -176,7 +176,7 @@ module Homebrew
|
|||||||
|
|
||||||
# Don't show the default formatter's progress dots
|
# Don't show the default formatter's progress dots
|
||||||
# on CI or if only checking a single file.
|
# on CI or if only checking a single file.
|
||||||
args << "--format" << "clang" if ENV["CI"] || files.count { |f| !f.directory? } == 1
|
args << "--format" << "clang" if ENV["CI"] || files.one? { |f| !f.directory? }
|
||||||
|
|
||||||
args << "--color" if Tty.color?
|
args << "--color" if Tty.color?
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.run_shfmt(files, fix: false)
|
def self.run_shfmt!(files, fix: false)
|
||||||
files = shell_scripts if files.blank?
|
files = shell_scripts if files.blank?
|
||||||
# Do not format completions and Dockerfile
|
# Do not format completions and Dockerfile
|
||||||
files.delete(HOMEBREW_REPOSITORY/"completions/bash/brew")
|
files.delete(HOMEBREW_REPOSITORY/"completions/bash/brew")
|
||||||
@ -277,7 +277,7 @@ module Homebrew
|
|||||||
$CHILD_STATUS.success?
|
$CHILD_STATUS.success?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.run_actionlint(files)
|
def self.run_actionlint!(files)
|
||||||
files = github_workflow_files if files.blank?
|
files = github_workflow_files if files.blank?
|
||||||
# the ignore is to avoid false positives in e.g. actions, homebrew-test-bot
|
# the ignore is to avoid false positives in e.g. actions, homebrew-test-bot
|
||||||
system actionlint, "-shellcheck", shellcheck,
|
system actionlint, "-shellcheck", shellcheck,
|
||||||
|
|||||||
@ -55,7 +55,7 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
|||||||
|
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(Homebrew::Bundle).not_to receive(:system)
|
expect(Homebrew::Bundle).not_to receive(:system)
|
||||||
expect(described_class.preinstall("google-chrome")).to be(false)
|
expect(described_class.preinstall!("google-chrome")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -69,8 +69,8 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
|||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--cask", "google-chrome", verbose: false)
|
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--cask", "google-chrome", verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect(described_class.preinstall("google-chrome")).to be(true)
|
expect(described_class.preinstall!("google-chrome")).to be(true)
|
||||||
expect(described_class.install("google-chrome")).to be(true)
|
expect(described_class.install!("google-chrome")).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -85,8 +85,8 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
|||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--cask", "opera", verbose: false)
|
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--cask", "opera", verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect(described_class.preinstall("opera", greedy: true)).to be(true)
|
expect(described_class.preinstall!("opera", greedy: true)).to be(true)
|
||||||
expect(described_class.install("opera", greedy: true)).to be(true)
|
expect(described_class.install!("opera", greedy: true)).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -99,8 +99,8 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
|||||||
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "google-chrome", "--adopt",
|
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "google-chrome", "--adopt",
|
||||||
verbose: false)
|
verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect(described_class.preinstall("google-chrome")).to be(true)
|
expect(described_class.preinstall!("google-chrome")).to be(true)
|
||||||
expect(described_class.install("google-chrome")).to be(true)
|
expect(described_class.install!("google-chrome")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs cask with arguments" do
|
it "installs cask with arguments" do
|
||||||
@ -109,16 +109,16 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
|||||||
verbose: false)
|
verbose: false)
|
||||||
.and_return(true),
|
.and_return(true),
|
||||||
)
|
)
|
||||||
expect(described_class.preinstall("firefox", args: { appdir: "/Applications" })).to be(true)
|
expect(described_class.preinstall!("firefox", args: { appdir: "/Applications" })).to be(true)
|
||||||
expect(described_class.install("firefox", args: { appdir: "/Applications" })).to be(true)
|
expect(described_class.install!("firefox", args: { appdir: "/Applications" })).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports a failure" do
|
it "reports a failure" do
|
||||||
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "google-chrome", "--adopt",
|
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "google-chrome", "--adopt",
|
||||||
verbose: false)
|
verbose: false)
|
||||||
.and_return(false)
|
.and_return(false)
|
||||||
expect(described_class.preinstall("google-chrome")).to be(true)
|
expect(described_class.preinstall!("google-chrome")).to be(true)
|
||||||
expect(described_class.install("google-chrome")).to be(false)
|
expect(described_class.install!("google-chrome")).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with boolean arguments" do
|
context "with boolean arguments" do
|
||||||
@ -126,15 +126,15 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
|||||||
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "iterm", "--force",
|
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "iterm", "--force",
|
||||||
verbose: false)
|
verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect(described_class.preinstall("iterm", args: { force: true })).to be(true)
|
expect(described_class.preinstall!("iterm", args: { force: true })).to be(true)
|
||||||
expect(described_class.install("iterm", args: { force: true })).to be(true)
|
expect(described_class.install!("iterm", args: { force: true })).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not include a flag if false" do
|
it "does not include a flag if false" do
|
||||||
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "iterm", "--adopt", verbose: false)
|
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "iterm", "--adopt", verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect(described_class.preinstall("iterm", args: { force: false })).to be(true)
|
expect(described_class.preinstall!("iterm", args: { force: false })).to be(true)
|
||||||
expect(described_class.install("iterm", args: { force: false })).to be(true)
|
expect(described_class.install!("iterm", args: { force: false })).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -150,14 +150,14 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
|||||||
|
|
||||||
it "runs the postinstall command" do
|
it "runs the postinstall command" do
|
||||||
expect(Kernel).to receive(:system).with("custom command").and_return(true)
|
expect(Kernel).to receive(:system).with("custom command").and_return(true)
|
||||||
expect(described_class.preinstall("google-chrome", postinstall: "custom command")).to be(true)
|
expect(described_class.preinstall!("google-chrome", postinstall: "custom command")).to be(true)
|
||||||
expect(described_class.install("google-chrome", postinstall: "custom command")).to be(true)
|
expect(described_class.install!("google-chrome", postinstall: "custom command")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports a failure when postinstall fails" do
|
it "reports a failure when postinstall fails" do
|
||||||
expect(Kernel).to receive(:system).with("custom command").and_return(false)
|
expect(Kernel).to receive(:system).with("custom command").and_return(false)
|
||||||
expect(described_class.preinstall("google-chrome", postinstall: "custom command")).to be(true)
|
expect(described_class.preinstall!("google-chrome", postinstall: "custom command")).to be(true)
|
||||||
expect(described_class.install("google-chrome", postinstall: "custom command")).to be(false)
|
expect(described_class.install!("google-chrome", postinstall: "custom command")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -28,28 +28,28 @@ RSpec.describe Homebrew::Bundle::Commands::Install do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "does not raise an error" do
|
it "does not raise an error" do
|
||||||
allow(Homebrew::Bundle::TapInstaller).to receive(:preinstall).and_return(false)
|
allow(Homebrew::Bundle::TapInstaller).to receive(:preinstall!).and_return(false)
|
||||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive(:preinstall).and_return(false)
|
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive(:preinstall!).and_return(false)
|
||||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
||||||
expect { described_class.run }.not_to raise_error
|
expect { described_class.run }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "#dsl returns a valid DSL" do
|
it "#dsl returns a valid DSL" do
|
||||||
allow(Homebrew::Bundle::TapInstaller).to receive(:preinstall).and_return(false)
|
allow(Homebrew::Bundle::TapInstaller).to receive(:preinstall!).and_return(false)
|
||||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive(:preinstall).and_return(false)
|
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive(:preinstall!).and_return(false)
|
||||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
||||||
described_class.run
|
described_class.run
|
||||||
expect(described_class.dsl.entries.first.name).to eql("phinze/cask")
|
expect(described_class.dsl.entries.first.name).to eql("phinze/cask")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not raise an error when skippable" do
|
it "does not raise an error when skippable" do
|
||||||
expect(Homebrew::Bundle::FormulaInstaller).not_to receive(:install)
|
expect(Homebrew::Bundle::FormulaInstaller).not_to receive(:install!)
|
||||||
|
|
||||||
allow(Homebrew::Bundle::Skipper).to receive(:skip?).and_return(true)
|
allow(Homebrew::Bundle::Skipper).to receive(:skip?).and_return(true)
|
||||||
allow_any_instance_of(Pathname).to receive(:read)
|
allow_any_instance_of(Pathname).to receive(:read)
|
||||||
@ -58,22 +58,22 @@ RSpec.describe Homebrew::Bundle::Commands::Install do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "exits on failures" do
|
it "exits on failures" do
|
||||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall: true, install: false)
|
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall: true, install: false)
|
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: false)
|
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||||
allow(Homebrew::Bundle::TapInstaller).to receive_messages(preinstall: true, install: false)
|
allow(Homebrew::Bundle::TapInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive_messages(preinstall: true, install: false)
|
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||||
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
||||||
|
|
||||||
expect { described_class.run }.to raise_error(SystemExit)
|
expect { described_class.run }.to raise_error(SystemExit)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "skips installs from failed taps" do
|
it "skips installs from failed taps" do
|
||||||
allow(Homebrew::Bundle::CaskInstaller).to receive(:preinstall).and_return(false)
|
allow(Homebrew::Bundle::CaskInstaller).to receive(:preinstall!).and_return(false)
|
||||||
allow(Homebrew::Bundle::TapInstaller).to receive_messages(preinstall: true, install: false)
|
allow(Homebrew::Bundle::TapInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive_messages(preinstall: true, install: true)
|
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||||
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
||||||
|
|
||||||
expect(Homebrew::Bundle).not_to receive(:system)
|
expect(Homebrew::Bundle).not_to receive(:system)
|
||||||
|
|||||||
@ -37,15 +37,15 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
context "with a successful installation" do
|
context "with a successful installation" do
|
||||||
it "start service" do
|
it "start service" do
|
||||||
expect(Homebrew::Bundle::BrewServices).not_to receive(:start)
|
expect(Homebrew::Bundle::BrewServices).not_to receive(:start)
|
||||||
described_class.preinstall(formula_name, start_service: true)
|
described_class.preinstall!(formula_name, start_service: true)
|
||||||
described_class.install(formula_name, start_service: true)
|
described_class.install!(formula_name, start_service: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with a skipped installation" do
|
context "with a skipped installation" do
|
||||||
it "start service" do
|
it "start service" do
|
||||||
expect(Homebrew::Bundle::BrewServices).not_to receive(:start)
|
expect(Homebrew::Bundle::BrewServices).not_to receive(:start)
|
||||||
described_class.install(formula_name, preinstall: false, start_service: true)
|
described_class.install!(formula_name, preinstall: false, start_service: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -59,8 +59,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
it "start service" do
|
it "start service" do
|
||||||
expect(Homebrew::Bundle::BrewServices).to \
|
expect(Homebrew::Bundle::BrewServices).to \
|
||||||
receive(:start).with(formula_name, file: nil, verbose: false).and_return(true)
|
receive(:start).with(formula_name, file: nil, verbose: false).and_return(true)
|
||||||
described_class.preinstall(formula_name, start_service: true)
|
described_class.preinstall!(formula_name, start_service: true)
|
||||||
described_class.install(formula_name, start_service: true)
|
described_class.install!(formula_name, start_service: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
it "start service" do
|
it "start service" do
|
||||||
expect(Homebrew::Bundle::BrewServices).to \
|
expect(Homebrew::Bundle::BrewServices).to \
|
||||||
receive(:start).with(formula_name, file: nil, verbose: false).and_return(true)
|
receive(:start).with(formula_name, file: nil, verbose: false).and_return(true)
|
||||||
described_class.install(formula_name, preinstall: false, start_service: true)
|
described_class.install!(formula_name, preinstall: false, start_service: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -84,8 +84,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
it "restart service" do
|
it "restart service" do
|
||||||
expect(Homebrew::Bundle::BrewServices).to \
|
expect(Homebrew::Bundle::BrewServices).to \
|
||||||
receive(:restart).with(formula_name, file: nil, verbose: false).and_return(true)
|
receive(:restart).with(formula_name, file: nil, verbose: false).and_return(true)
|
||||||
described_class.preinstall(formula_name, restart_service: :always)
|
described_class.preinstall!(formula_name, restart_service: :always)
|
||||||
described_class.install(formula_name, restart_service: :always)
|
described_class.install!(formula_name, restart_service: :always)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
it "restart service" do
|
it "restart service" do
|
||||||
expect(Homebrew::Bundle::BrewServices).to \
|
expect(Homebrew::Bundle::BrewServices).to \
|
||||||
receive(:restart).with(formula_name, file: nil, verbose: false).and_return(true)
|
receive(:restart).with(formula_name, file: nil, verbose: false).and_return(true)
|
||||||
described_class.install(formula_name, preinstall: false, restart_service: :always)
|
described_class.install!(formula_name, preinstall: false, restart_service: :always)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -107,8 +107,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
allow_any_instance_of(described_class).to receive(:linked?).and_return(false)
|
allow_any_instance_of(described_class).to receive(:linked?).and_return(false)
|
||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "mysql",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "mysql",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
described_class.preinstall(formula_name, link: true)
|
described_class.preinstall!(formula_name, link: true)
|
||||||
described_class.install(formula_name, link: true)
|
described_class.install!(formula_name, link: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "force-links keg-only formula" do
|
it "force-links keg-only formula" do
|
||||||
@ -116,8 +116,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
allow_any_instance_of(described_class).to receive(:keg_only?).and_return(true)
|
allow_any_instance_of(described_class).to receive(:keg_only?).and_return(true)
|
||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "--force", "mysql",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "--force", "mysql",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
described_class.preinstall(formula_name, link: true)
|
described_class.preinstall!(formula_name, link: true)
|
||||||
described_class.install(formula_name, link: true)
|
described_class.install!(formula_name, link: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -130,8 +130,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
allow_any_instance_of(described_class).to receive(:linked?).and_return(false)
|
allow_any_instance_of(described_class).to receive(:linked?).and_return(false)
|
||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "--overwrite", "mysql",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "--overwrite", "mysql",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
described_class.preinstall(formula_name, link: :overwrite)
|
described_class.preinstall!(formula_name, link: :overwrite)
|
||||||
described_class.install(formula_name, link: :overwrite)
|
described_class.install!(formula_name, link: :overwrite)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -144,8 +144,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
allow_any_instance_of(described_class).to receive(:linked?).and_return(true)
|
allow_any_instance_of(described_class).to receive(:linked?).and_return(true)
|
||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "unlink", "mysql",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "unlink", "mysql",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
described_class.preinstall(formula_name, link: false)
|
described_class.preinstall!(formula_name, link: false)
|
||||||
described_class.install(formula_name, link: false)
|
described_class.install!(formula_name, link: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -159,8 +159,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
it "links formula" do
|
it "links formula" do
|
||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "mysql",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "mysql",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
described_class.preinstall(formula_name, link: nil)
|
described_class.preinstall!(formula_name, link: nil)
|
||||||
described_class.install(formula_name, link: nil)
|
described_class.install!(formula_name, link: nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -174,9 +174,9 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
it "unlinks formula" do
|
it "unlinks formula" do
|
||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "unlink", "mysql",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "unlink", "mysql",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
described_class.preinstall(formula_name, link: nil)
|
described_class.preinstall!(formula_name, link: nil)
|
||||||
|
|
||||||
described_class.install(formula_name, link: nil)
|
described_class.install!(formula_name, link: nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -188,8 +188,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
conflicts_with: ["mysql55"],
|
conflicts_with: ["mysql55"],
|
||||||
)
|
)
|
||||||
allow(described_class).to receive(:formula_installed?).and_return(true)
|
allow(described_class).to receive(:formula_installed?).and_return(true)
|
||||||
allow_any_instance_of(described_class).to receive(:install!).and_return(true)
|
allow_any_instance_of(described_class).to receive(:install_formula!).and_return(true)
|
||||||
allow_any_instance_of(described_class).to receive(:upgrade!).and_return(true)
|
allow_any_instance_of(described_class).to receive(:upgrade_formula!).and_return(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "unlinks conflicts and stops their services" do
|
it "unlinks conflicts and stops their services" do
|
||||||
@ -203,8 +203,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
expect(Homebrew::Bundle::BrewServices).to receive(:stop).with("mysql56", verbose:).and_return(true)
|
expect(Homebrew::Bundle::BrewServices).to receive(:stop).with("mysql56", verbose:).and_return(true)
|
||||||
expect(Homebrew::Bundle::BrewServices).to receive(:restart).with(formula_name, file: nil,
|
expect(Homebrew::Bundle::BrewServices).to receive(:restart).with(formula_name, file: nil,
|
||||||
verbose:).and_return(true)
|
verbose:).and_return(true)
|
||||||
described_class.preinstall(formula_name, restart_service: :always, conflicts_with: ["mysql56"])
|
described_class.preinstall!(formula_name, restart_service: :always, conflicts_with: ["mysql56"])
|
||||||
described_class.install(formula_name, restart_service: :always, conflicts_with: ["mysql56"])
|
described_class.install!(formula_name, restart_service: :always, conflicts_with: ["mysql56"])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints a message" do
|
it "prints a message" do
|
||||||
@ -219,8 +219,10 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
expect(Homebrew::Bundle::BrewServices).to receive(:stop).with("mysql56", verbose:).and_return(true)
|
expect(Homebrew::Bundle::BrewServices).to receive(:stop).with("mysql56", verbose:).and_return(true)
|
||||||
expect(Homebrew::Bundle::BrewServices).to receive(:restart).with(formula_name, file: nil,
|
expect(Homebrew::Bundle::BrewServices).to receive(:restart).with(formula_name, file: nil,
|
||||||
verbose:).and_return(true)
|
verbose:).and_return(true)
|
||||||
described_class.preinstall(formula_name, restart_service: :always, conflicts_with: ["mysql56"], verbose: true)
|
described_class.preinstall!(formula_name, restart_service: :always, conflicts_with: ["mysql56"],
|
||||||
described_class.install(formula_name, restart_service: :always, conflicts_with: ["mysql56"], verbose: true)
|
verbose: true)
|
||||||
|
described_class.install!(formula_name, restart_service: :always, conflicts_with: ["mysql56"],
|
||||||
|
verbose: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -237,14 +239,14 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
|
|
||||||
it "runs the postinstall command" do
|
it "runs the postinstall command" do
|
||||||
expect(Kernel).to receive(:system).with("custom command").and_return(true)
|
expect(Kernel).to receive(:system).with("custom command").and_return(true)
|
||||||
described_class.preinstall(formula_name, postinstall: "custom command")
|
described_class.preinstall!(formula_name, postinstall: "custom command")
|
||||||
described_class.install(formula_name, postinstall: "custom command")
|
described_class.install!(formula_name, postinstall: "custom command")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports a failure" do
|
it "reports a failure" do
|
||||||
expect(Kernel).to receive(:system).with("custom command").and_return(false)
|
expect(Kernel).to receive(:system).with("custom command").and_return(false)
|
||||||
described_class.preinstall(formula_name, postinstall: "custom command")
|
described_class.preinstall!(formula_name, postinstall: "custom command")
|
||||||
expect(described_class.install(formula_name, postinstall: "custom command")).to be(false)
|
expect(described_class.install!(formula_name, postinstall: "custom command")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -255,8 +257,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
|
|
||||||
it "does not run the postinstall command" do
|
it "does not run the postinstall command" do
|
||||||
expect(Kernel).not_to receive(:system)
|
expect(Kernel).not_to receive(:system)
|
||||||
described_class.preinstall(formula_name, postinstall: "custom command")
|
described_class.preinstall!(formula_name, postinstall: "custom command")
|
||||||
described_class.install(formula_name, postinstall: "custom command")
|
described_class.install!(formula_name, postinstall: "custom command")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -281,16 +283,16 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
|
|
||||||
it "writes the version to the file" do
|
it "writes the version to the file" do
|
||||||
expect(File).to receive(:write).with(version_file, "#{version}\n")
|
expect(File).to receive(:write).with(version_file, "#{version}\n")
|
||||||
described_class.preinstall(formula_name, version_file:)
|
described_class.preinstall!(formula_name, version_file:)
|
||||||
described_class.install(formula_name, version_file:)
|
described_class.install!(formula_name, version_file:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when using the latest formula" do
|
context "when using the latest formula" do
|
||||||
it "writes the version to the file" do
|
it "writes the version to the file" do
|
||||||
expect(File).to receive(:write).with(version_file, "#{version}\n")
|
expect(File).to receive(:write).with(version_file, "#{version}\n")
|
||||||
described_class.preinstall(formula_name, version_file:)
|
described_class.preinstall!(formula_name, version_file:)
|
||||||
described_class.install(formula_name, version_file:)
|
described_class.install!(formula_name, version_file:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -304,7 +306,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
|
|
||||||
it "did not call restart service" do
|
it "did not call restart service" do
|
||||||
expect(Homebrew::Bundle::BrewServices).not_to receive(:restart)
|
expect(Homebrew::Bundle::BrewServices).not_to receive(:restart)
|
||||||
described_class.preinstall(formula_name, restart_service: true)
|
described_class.preinstall!(formula_name, restart_service: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -386,16 +388,16 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
expect(Homebrew::Bundle).to receive(:system)
|
expect(Homebrew::Bundle).to receive(:system)
|
||||||
.with(HOMEBREW_BREW_FILE, "install", "--formula", formula_name, "--with-option", verbose: false)
|
.with(HOMEBREW_BREW_FILE, "install", "--formula", formula_name, "--with-option", verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect(installer.preinstall).to be(true)
|
expect(installer.preinstall!).to be(true)
|
||||||
expect(installer.install).to be(true)
|
expect(installer.install!).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports a failure" do
|
it "reports a failure" do
|
||||||
expect(Homebrew::Bundle).to receive(:system)
|
expect(Homebrew::Bundle).to receive(:system)
|
||||||
.with(HOMEBREW_BREW_FILE, "install", "--formula", formula_name, "--with-option", verbose: false)
|
.with(HOMEBREW_BREW_FILE, "install", "--formula", formula_name, "--with-option", verbose: false)
|
||||||
.and_return(false)
|
.and_return(false)
|
||||||
expect(installer.preinstall).to be(true)
|
expect(installer.preinstall!).to be(true)
|
||||||
expect(installer.install).to be(false)
|
expect(installer.install!).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -416,16 +418,16 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect(installer.preinstall).to be(true)
|
expect(installer.preinstall!).to be(true)
|
||||||
expect(installer.install).to be(true)
|
expect(installer.install!).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports a failure" do
|
it "reports a failure" do
|
||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
||||||
.and_return(false)
|
.and_return(false)
|
||||||
expect(installer.preinstall).to be(true)
|
expect(installer.preinstall!).to be(true)
|
||||||
expect(installer.install).to be(false)
|
expect(installer.install!).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when formula pinned" do
|
context "when formula pinned" do
|
||||||
@ -436,7 +438,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
it "does not upgrade formula" do
|
it "does not upgrade formula" do
|
||||||
expect(Homebrew::Bundle).not_to \
|
expect(Homebrew::Bundle).not_to \
|
||||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
||||||
expect(installer.preinstall).to be(false)
|
expect(installer.preinstall!).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -447,7 +449,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
|||||||
|
|
||||||
it "does not upgrade formula" do
|
it "does not upgrade formula" do
|
||||||
expect(Homebrew::Bundle).not_to receive(:system)
|
expect(Homebrew::Bundle).not_to receive(:system)
|
||||||
expect(installer.preinstall).to be(false)
|
expect(installer.preinstall!).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -30,7 +30,7 @@ RSpec.describe Homebrew::Bundle::MacAppStoreInstaller do
|
|||||||
it "tries to install mas" do
|
it "tries to install mas" do
|
||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "install", "mas",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "install", "mas",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
expect { described_class.preinstall("foo", 123) }.to raise_error(RuntimeError)
|
expect { described_class.preinstall!("foo", 123) }.to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".outdated_app_ids" do
|
describe ".outdated_app_ids" do
|
||||||
@ -62,7 +62,7 @@ RSpec.describe Homebrew::Bundle::MacAppStoreInstaller do
|
|||||||
|
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(Homebrew::Bundle).not_to receive(:system)
|
expect(Homebrew::Bundle).not_to receive(:system)
|
||||||
expect(described_class.preinstall("foo", 123)).to be(false)
|
expect(described_class.preinstall!("foo", 123)).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -73,8 +73,8 @@ RSpec.describe Homebrew::Bundle::MacAppStoreInstaller do
|
|||||||
|
|
||||||
it "upgrades" do
|
it "upgrades" do
|
||||||
expect(Homebrew::Bundle).to receive(:system).with("mas", "upgrade", "123", verbose: false).and_return(true)
|
expect(Homebrew::Bundle).to receive(:system).with("mas", "upgrade", "123", verbose: false).and_return(true)
|
||||||
expect(described_class.preinstall("foo", 123)).to be(true)
|
expect(described_class.preinstall!("foo", 123)).to be(true)
|
||||||
expect(described_class.install("foo", 123)).to be(true)
|
expect(described_class.install!("foo", 123)).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -85,8 +85,8 @@ RSpec.describe Homebrew::Bundle::MacAppStoreInstaller do
|
|||||||
|
|
||||||
it "installs app" do
|
it "installs app" do
|
||||||
expect(Homebrew::Bundle).to receive(:system).with("mas", "install", "123", verbose: false).and_return(true)
|
expect(Homebrew::Bundle).to receive(:system).with("mas", "install", "123", verbose: false).and_return(true)
|
||||||
expect(described_class.preinstall("foo", 123)).to be(true)
|
expect(described_class.preinstall!("foo", 123)).to be(true)
|
||||||
expect(described_class.install("foo", 123)).to be(true)
|
expect(described_class.install!("foo", 123)).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -22,7 +22,7 @@ RSpec.describe Homebrew::Bundle::TapInstaller do
|
|||||||
|
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(Homebrew::Bundle).not_to receive(:system)
|
expect(Homebrew::Bundle).not_to receive(:system)
|
||||||
expect(described_class.preinstall("homebrew/cask")).to be(false)
|
expect(described_class.preinstall!("homebrew/cask")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ RSpec.describe Homebrew::Bundle::TapInstaller do
|
|||||||
it "taps" do
|
it "taps" do
|
||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
expect(described_class.preinstall("homebrew/cask")).to be(true)
|
expect(described_class.preinstall!("homebrew/cask")).to be(true)
|
||||||
expect(described_class.install("homebrew/cask")).to be(true)
|
expect(described_class.install!("homebrew/cask")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with clone target" do
|
context "with clone target" do
|
||||||
@ -43,16 +43,16 @@ RSpec.describe Homebrew::Bundle::TapInstaller do
|
|||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask", "clone_target_path",
|
receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask", "clone_target_path",
|
||||||
verbose: false).and_return(true)
|
verbose: false).and_return(true)
|
||||||
expect(described_class.preinstall("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
expect(described_class.preinstall!("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||||
expect(described_class.install("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
expect(described_class.install!("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails" do
|
it "fails" do
|
||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask", "clone_target_path",
|
receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask", "clone_target_path",
|
||||||
verbose: false).and_return(false)
|
verbose: false).and_return(false)
|
||||||
expect(described_class.preinstall("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
expect(described_class.preinstall!("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||||
expect(described_class.install("homebrew/cask", clone_target: "clone_target_path")).to be(false)
|
expect(described_class.install!("homebrew/cask", clone_target: "clone_target_path")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -15,7 +15,7 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
|||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(HOMEBREW_BREW_FILE, "install", "--cask", "visual-studio-code", verbose: false)
|
receive(:system).with(HOMEBREW_BREW_FILE, "install", "--cask", "visual-studio-code", verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect { described_class.preinstall("foo") }.to raise_error(RuntimeError)
|
expect { described_class.preinstall!("foo") }.to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
|||||||
|
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(Homebrew::Bundle).not_to receive(:system)
|
expect(Homebrew::Bundle).not_to receive(:system)
|
||||||
expect(described_class.preinstall("foo")).to be(false)
|
expect(described_class.preinstall!("foo")).to be(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "skips ignoring case" do
|
it "skips ignoring case" do
|
||||||
expect(Homebrew::Bundle).not_to receive(:system)
|
expect(Homebrew::Bundle).not_to receive(:system)
|
||||||
expect(described_class.preinstall("Foo")).to be(false)
|
expect(described_class.preinstall!("Foo")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
|||||||
it "installs extension" do
|
it "installs extension" do
|
||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
||||||
expect(described_class.preinstall("foo")).to be(true)
|
expect(described_class.preinstall!("foo")).to be(true)
|
||||||
expect(described_class.install("foo")).to be(true)
|
expect(described_class.install!("foo")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs extension when euid != uid and Process::UID.re_exchangeable? returns true" do
|
it "installs extension when euid != uid and Process::UID.re_exchangeable? returns true" do
|
||||||
@ -59,8 +59,8 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
|||||||
|
|
||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
||||||
expect(described_class.preinstall("foo")).to be(true)
|
expect(described_class.preinstall!("foo")).to be(true)
|
||||||
expect(described_class.install("foo")).to be(true)
|
expect(described_class.install!("foo")).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "installs extension when euid != uid and Process::UID.re_exchangeable? returns false" do
|
it "installs extension when euid != uid and Process::UID.re_exchangeable? returns false" do
|
||||||
@ -70,8 +70,8 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
|||||||
|
|
||||||
expect(Homebrew::Bundle).to \
|
expect(Homebrew::Bundle).to \
|
||||||
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
||||||
expect(described_class.preinstall("foo")).to be(true)
|
expect(described_class.preinstall!("foo")).to be(true)
|
||||||
expect(described_class.install("foo")).to be(true)
|
expect(described_class.install!("foo")).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -42,7 +42,7 @@ RSpec.describe Homebrew::Bundle::WhalebrewInstaller do
|
|||||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "install", "--formula", "whalebrew",
|
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "install", "--formula", "whalebrew",
|
||||||
verbose: false)
|
verbose: false)
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
expect { described_class.preinstall("whalebrew/wget") }.to raise_error(RuntimeError)
|
expect { described_class.preinstall!("whalebrew/wget") }.to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ RSpec.describe Homebrew::Bundle::WhalebrewInstaller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "skips" do
|
it "skips" do
|
||||||
expect(described_class.preinstall("whalebrew/wget")).to be(false)
|
expect(described_class.preinstall!("whalebrew/wget")).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -59,7 +59,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
expect(renamed_app_new_path).not_to be_a_directory
|
expect(renamed_app_new_path).not_to be_a_directory
|
||||||
expect(renamed_app.installed_version).to eq "1.0.0"
|
expect(renamed_app.installed_version).to eq "1.0.0"
|
||||||
|
|
||||||
described_class.upgrade_casks(dry_run: true, args:)
|
described_class.upgrade_casks!(dry_run: true, args:)
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
@ -86,7 +86,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
expect(local_transmission_path).to be_a_directory
|
expect(local_transmission_path).to be_a_directory
|
||||||
expect(local_transmission.installed_version).to eq "2.60"
|
expect(local_transmission.installed_version).to eq "2.60"
|
||||||
|
|
||||||
described_class.upgrade_casks(local_caffeine, dry_run: true, args:)
|
described_class.upgrade_casks!(local_caffeine, dry_run: true, args:)
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
@ -113,7 +113,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
expect(renamed_app_new_path).not_to be_a_directory
|
expect(renamed_app_new_path).not_to be_a_directory
|
||||||
expect(renamed_app.installed_version).to eq "1.0.0"
|
expect(renamed_app.installed_version).to eq "1.0.0"
|
||||||
|
|
||||||
described_class.upgrade_casks(local_caffeine, auto_updates, dry_run: true, args:)
|
described_class.upgrade_casks!(local_caffeine, auto_updates, dry_run: true, args:)
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
@ -156,7 +156,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
version_latest.download_sha_path.write("fake download sha")
|
version_latest.download_sha_path.write("fake download sha")
|
||||||
expect(version_latest.outdated_download_sha?).to be(true)
|
expect(version_latest.outdated_download_sha?).to be(true)
|
||||||
|
|
||||||
described_class.upgrade_casks(greedy: true, dry_run: true, args:)
|
described_class.upgrade_casks!(greedy: true, dry_run: true, args:)
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
@ -186,7 +186,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
expect(auto_updates_path).to be_a_directory
|
expect(auto_updates_path).to be_a_directory
|
||||||
expect(auto_updates.installed_version).to eq "2.57"
|
expect(auto_updates.installed_version).to eq "2.57"
|
||||||
|
|
||||||
described_class.upgrade_casks(auto_updates, dry_run: true, greedy: true, args:)
|
described_class.upgrade_casks!(auto_updates, dry_run: true, greedy: true, args:)
|
||||||
|
|
||||||
expect(auto_updates).to be_installed
|
expect(auto_updates).to be_installed
|
||||||
expect(auto_updates_path).to be_a_directory
|
expect(auto_updates_path).to be_a_directory
|
||||||
@ -203,7 +203,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
version_latest.download_sha_path.write("fake download sha")
|
version_latest.download_sha_path.write("fake download sha")
|
||||||
expect(version_latest.outdated_download_sha?).to be(true)
|
expect(version_latest.outdated_download_sha?).to be(true)
|
||||||
|
|
||||||
described_class.upgrade_casks(version_latest, dry_run: true, greedy: true, args:)
|
described_class.upgrade_casks!(version_latest, dry_run: true, greedy: true, args:)
|
||||||
|
|
||||||
expect(version_latest).to be_installed
|
expect(version_latest).to be_installed
|
||||||
expect(version_latest_paths).to all be_a_directory
|
expect(version_latest_paths).to all be_a_directory
|
||||||
@ -234,7 +234,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
expect(will_fail_if_upgraded.installed_version).to eq "1.2.2"
|
expect(will_fail_if_upgraded.installed_version).to eq "1.2.2"
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
described_class.upgrade_casks(will_fail_if_upgraded, args:)
|
described_class.upgrade_casks!(will_fail_if_upgraded, args:)
|
||||||
end.to raise_error(Cask::CaskError).and output(output_reverted).to_stderr
|
end.to raise_error(Cask::CaskError).and output(output_reverted).to_stderr
|
||||||
|
|
||||||
expect(will_fail_if_upgraded).to be_installed
|
expect(will_fail_if_upgraded).to be_installed
|
||||||
@ -252,7 +252,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
expect(bad_checksum.installed_version).to eq "1.2.2"
|
expect(bad_checksum.installed_version).to eq "1.2.2"
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
described_class.upgrade_casks(bad_checksum, args:)
|
described_class.upgrade_casks!(bad_checksum, args:)
|
||||||
end.to raise_error(ChecksumMismatchError).and(not_to_output(output_reverted).to_stderr)
|
end.to raise_error(ChecksumMismatchError).and(not_to_output(output_reverted).to_stderr)
|
||||||
|
|
||||||
expect(bad_checksum).to be_installed
|
expect(bad_checksum).to be_installed
|
||||||
@ -291,7 +291,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
|||||||
expect(bad_checksum_2.installed_version).to eq "1.2.2"
|
expect(bad_checksum_2.installed_version).to eq "1.2.2"
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
described_class.upgrade_casks(args:)
|
described_class.upgrade_casks!(args:)
|
||||||
end.to raise_error(Cask::MultipleCaskErrors)
|
end.to raise_error(Cask::MultipleCaskErrors)
|
||||||
|
|
||||||
expect(bad_checksum).to be_installed
|
expect(bad_checksum).to be_installed
|
||||||
|
|||||||
@ -5,9 +5,12 @@ require "extend/blank"
|
|||||||
RSpec.describe Object do
|
RSpec.describe Object do
|
||||||
let(:empty_true) do
|
let(:empty_true) do
|
||||||
Class.new(described_class) do
|
Class.new(described_class) do
|
||||||
|
# This API is intentionally non-ideal for testing.
|
||||||
|
# rubocop:disable Naming/PredicateMethod
|
||||||
def empty?
|
def empty?
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Naming/PredicateMethod
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
let(:empty_false) do
|
let(:empty_false) do
|
||||||
|
|||||||
@ -32,11 +32,11 @@ RSpec.describe Keg::Relocation do
|
|||||||
expect(relocation.replacement_pair_for(:library_placeholder)).to eq [library_placeholder, library]
|
expect(relocation.replacement_pair_for(:library_placeholder)).to eq [library_placeholder, library]
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#replace_text" do
|
specify "#replace_text!" do
|
||||||
relocation = setup_relocation
|
relocation = setup_relocation
|
||||||
|
|
||||||
text = +"foo"
|
text = +"foo"
|
||||||
relocation.replace_text(text)
|
relocation.replace_text!(text)
|
||||||
expect(text).to eq "foo"
|
expect(text).to eq "foo"
|
||||||
|
|
||||||
text = <<~TEXT
|
text = <<~TEXT
|
||||||
@ -47,7 +47,7 @@ RSpec.describe Keg::Relocation do
|
|||||||
#{repository_placeholder}/foo
|
#{repository_placeholder}/foo
|
||||||
foo#{library_placeholder}/bar
|
foo#{library_placeholder}/bar
|
||||||
TEXT
|
TEXT
|
||||||
relocation.replace_text(text)
|
relocation.replace_text!(text)
|
||||||
expect(text).to eq <<~REPLACED
|
expect(text).to eq <<~REPLACED
|
||||||
#{prefix_placeholder}/foo
|
#{prefix_placeholder}/foo
|
||||||
#{cellar_placeholder}/foo
|
#{cellar_placeholder}/foo
|
||||||
|
|||||||
@ -42,16 +42,16 @@ RSpec.describe Homebrew::Services::Cli do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#check" do
|
describe "#check!" do
|
||||||
it "checks the input does not exist" do
|
it "checks the input does not exist" do
|
||||||
expect do
|
expect do
|
||||||
services_cli.check([])
|
services_cli.check!([])
|
||||||
end.to raise_error(UsageError, "Invalid usage: Formula(e) missing, please provide a formula name or use --all")
|
end.to raise_error(UsageError, "Invalid usage: Formula(e) missing, please provide a formula name or use --all")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "checks the input exists" do
|
it "checks the input exists" do
|
||||||
expect do
|
expect do
|
||||||
services_cli.check("hello")
|
services_cli.check!("hello")
|
||||||
end.not_to raise_error(UsageError,
|
end.not_to raise_error(UsageError,
|
||||||
"Invalid usage: Formula(e) missing, please provide a formula name or use --all")
|
"Invalid usage: Formula(e) missing, please provide a formula name or use --all")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,62 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require "tapioca/dsl"
|
|
||||||
require "sorbet/tapioca/compilers/args"
|
|
||||||
|
|
||||||
RSpec.describe Tapioca::Compilers::Args do
|
|
||||||
let(:compiler) { described_class.new(Tapioca::Dsl::Pipeline.new(requested_constants: []), RBI::Tree.new, Homebrew) }
|
|
||||||
let(:list_parser) do
|
|
||||||
require "cmd/list"
|
|
||||||
Homebrew::Cmd::List.parser
|
|
||||||
end
|
|
||||||
|
|
||||||
# Good testing candidate because it has multiple for each of `switch`, `flag` and `comma_array` args:
|
|
||||||
let(:update_python_resources_parser) do
|
|
||||||
require "dev-cmd/update-python-resources"
|
|
||||||
Homebrew::DevCmd::UpdatePythonResources.parser
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#args_table" do
|
|
||||||
it "returns a mapping of list args to default values" do
|
|
||||||
expect(compiler.args_table(list_parser)).to contain_exactly(
|
|
||||||
:"1?", :built_from_source?, :cask?, :casks?, :d?, :debug?, :formula?, :formulae?, :full_name?, :h?, :help?,
|
|
||||||
:installed_as_dependency?, :installed_on_request?, :l?, :multiple?, :pinned?, :poured_from_bottle?, :q?,
|
|
||||||
:quiet?, :r?, :t?, :v?, :verbose?, :versions?
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns a mapping of update-python-resources args to default values" do
|
|
||||||
expect(compiler.args_table(update_python_resources_parser)).to contain_exactly(
|
|
||||||
:d?, :debug?, :exclude_packages, :extra_packages, :h?, :help?, :ignore_errors?, :ignore_non_pypi_packages?,
|
|
||||||
:install_dependencies?, :p?, :package_name, :print_only?, :q?, :quiet?, :s?, :silent?, :v?, :verbose?,
|
|
||||||
:version
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#comma_arrays" do
|
|
||||||
it "returns an empty list when there are no comma_array args" do
|
|
||||||
expect(compiler.comma_arrays(list_parser)).to eq([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns the comma_array args when they exist" do
|
|
||||||
expect(compiler.comma_arrays(update_python_resources_parser)).to eq([:extra_packages, :exclude_packages])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#get_return_type" do
|
|
||||||
let(:comma_arrays) { compiler.comma_arrays(update_python_resources_parser) }
|
|
||||||
|
|
||||||
it "returns the correct type for switches" do
|
|
||||||
expect(compiler.get_return_type(:silent?, comma_arrays)).to eq("T::Boolean")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns the correct type for flags" do
|
|
||||||
expect(compiler.get_return_type(:package_name, comma_arrays)).to eq("T.nilable(String)")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns the correct type for comma_arrays" do
|
|
||||||
expect(compiler.get_return_type(:extra_packages, comma_arrays)).to eq("T.nilable(T::Array[String])")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -48,7 +48,7 @@ module Homebrew
|
|||||||
if rack.directory?
|
if rack.directory?
|
||||||
versions = rack.subdirs.map(&:basename)
|
versions = rack.subdirs.map(&:basename)
|
||||||
puts <<~EOS
|
puts <<~EOS
|
||||||
#{keg.name} #{versions.to_sentence} #{(versions.count == 1) ? "is" : "are"} still installed.
|
#{keg.name} #{versions.to_sentence} #{versions.one? ? "is" : "are"} still installed.
|
||||||
To remove all versions, run:
|
To remove all versions, run:
|
||||||
brew uninstall --force #{keg.name}
|
brew uninstall --force #{keg.name}
|
||||||
EOS
|
EOS
|
||||||
@ -108,13 +108,13 @@ module Homebrew
|
|||||||
return if ignore_dependencies
|
return if ignore_dependencies
|
||||||
|
|
||||||
all_kegs = kegs_by_rack.values.flatten(1)
|
all_kegs = kegs_by_rack.values.flatten(1)
|
||||||
check_for_dependents(all_kegs, casks:, named_args:)
|
check_for_dependents!(all_kegs, casks:, named_args:)
|
||||||
rescue MethodDeprecatedError
|
rescue MethodDeprecatedError
|
||||||
# Silently ignore deprecations when uninstalling.
|
# Silently ignore deprecations when uninstalling.
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.check_for_dependents(kegs, casks: [], named_args: [])
|
def self.check_for_dependents!(kegs, casks: [], named_args: [])
|
||||||
return false unless (result = InstalledDependents.find_some_installed_dependents(kegs, casks:))
|
return false unless (result = InstalledDependents.find_some_installed_dependents(kegs, casks:))
|
||||||
|
|
||||||
DependentsMessage.new(*result, named_args:).output
|
DependentsMessage.new(*result, named_args:).output
|
||||||
@ -133,7 +133,7 @@ module Homebrew
|
|||||||
def output
|
def output
|
||||||
ofail <<~EOS
|
ofail <<~EOS
|
||||||
Refusing to uninstall #{reqs.to_sentence}
|
Refusing to uninstall #{reqs.to_sentence}
|
||||||
because #{(reqs.count == 1) ? "it" : "they"} #{are_required_by_deps}.
|
because #{reqs.one? ? "it" : "they"} #{are_required_by_deps}.
|
||||||
You can override this and force removal with:
|
You can override this and force removal with:
|
||||||
#{sample_command}
|
#{sample_command}
|
||||||
EOS
|
EOS
|
||||||
@ -146,8 +146,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def are_required_by_deps
|
def are_required_by_deps
|
||||||
"#{(reqs.count == 1) ? "is" : "are"} required by #{deps.to_sentence}, " \
|
"#{reqs.one? ? "is" : "are"} required by #{deps.to_sentence}, " \
|
||||||
"which #{(deps.count == 1) ? "is" : "are"} currently installed"
|
"which #{deps.one? ? "is" : "are"} currently installed"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -72,17 +72,17 @@ module Homebrew
|
|||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def single_app_cask?
|
def single_app_cask?
|
||||||
apps.count == 1
|
apps.one?
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def single_qlplugin_cask?
|
def single_qlplugin_cask?
|
||||||
qlplugins.count == 1
|
qlplugins.one?
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def single_pkg_cask?
|
def single_pkg_cask?
|
||||||
pkgs.count == 1
|
pkgs.one?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Filter paths to `Info.plist` files so that ones belonging
|
# Filter paths to `Info.plist` files so that ones belonging
|
||||||
@ -222,14 +222,14 @@ module Homebrew
|
|||||||
unique_info_plist_versions =
|
unique_info_plist_versions =
|
||||||
top_level_info_plist_paths.filter_map { |i| BundleVersion.from_info_plist(i)&.nice_version }
|
top_level_info_plist_paths.filter_map { |i| BundleVersion.from_info_plist(i)&.nice_version }
|
||||||
.uniq
|
.uniq
|
||||||
return unique_info_plist_versions.first if unique_info_plist_versions.count == 1
|
return unique_info_plist_versions.first if unique_info_plist_versions.one?
|
||||||
|
|
||||||
package_info_path = extract_dir/"PackageInfo"
|
package_info_path = extract_dir/"PackageInfo"
|
||||||
if package_info_path.exist?
|
if package_info_path.exist?
|
||||||
if (version = BundleVersion.from_package_info(package_info_path))
|
if (version = BundleVersion.from_package_info(package_info_path))
|
||||||
return version.nice_version
|
return version.nice_version
|
||||||
end
|
end
|
||||||
elsif packages.count == 1
|
elsif packages.one?
|
||||||
onoe "#{pkg_path.basename} does not contain a `PackageInfo` file."
|
onoe "#{pkg_path.basename} does not contain a `PackageInfo` file."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@ require "context"
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
extend Context
|
extend Context
|
||||||
|
|
||||||
|
# Need to keep this naming as-is for backwards compatibility.
|
||||||
|
# rubocop:disable Naming/PredicateMethod
|
||||||
def self._system(cmd, *args, **options)
|
def self._system(cmd, *args, **options)
|
||||||
pid = fork do
|
pid = fork do
|
||||||
yield if block_given?
|
yield if block_given?
|
||||||
@ -20,6 +22,7 @@ module Homebrew
|
|||||||
Process.wait(T.must(pid))
|
Process.wait(T.must(pid))
|
||||||
$CHILD_STATUS.success?
|
$CHILD_STATUS.success?
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Naming/PredicateMethod
|
||||||
|
|
||||||
def self.system(cmd, *args, **options)
|
def self.system(cmd, *args, **options)
|
||||||
if verbose?
|
if verbose?
|
||||||
|
|||||||
@ -445,7 +445,7 @@ module Utils
|
|||||||
format "%#{index_width}s", index_header
|
format "%#{index_width}s", index_header
|
||||||
formatted_name_with_options_header =
|
formatted_name_with_options_header =
|
||||||
format "%-#{name_with_options_width}s",
|
format "%-#{name_with_options_width}s",
|
||||||
name_with_options_header[0..name_with_options_width-1]
|
name_with_options_header[0..(name_with_options_width-1)]
|
||||||
formatted_count_header =
|
formatted_count_header =
|
||||||
format "%#{count_width}s", count_header
|
format "%#{count_width}s", count_header
|
||||||
formatted_percent_header =
|
formatted_percent_header =
|
||||||
@ -464,7 +464,7 @@ module Utils
|
|||||||
formatted_index = format "%-#{index_width}s", formatted_index
|
formatted_index = format "%-#{index_width}s", formatted_index
|
||||||
formatted_name_with_options =
|
formatted_name_with_options =
|
||||||
format "%-#{name_with_options_width}s",
|
format "%-#{name_with_options_width}s",
|
||||||
name_with_options[0..name_with_options_width-1]
|
name_with_options[0..(name_with_options_width-1)]
|
||||||
formatted_count = format "%#{count_width}s", format_count(count)
|
formatted_count = format "%#{count_width}s", format_count(count)
|
||||||
formatted_percent = if total_count.zero?
|
formatted_percent = if total_count.zero?
|
||||||
format "%#{percent_width}s", format_percent(0)
|
format "%#{percent_width}s", format_percent(0)
|
||||||
|
|||||||
@ -45,7 +45,7 @@ module GitHub
|
|||||||
line: T.nilable(Integer)
|
line: T.nilable(Integer)
|
||||||
).returns(T::Boolean)
|
).returns(T::Boolean)
|
||||||
}
|
}
|
||||||
def self.puts_annotation_if_env_set(type, message, file: nil, line: nil)
|
def self.puts_annotation_if_env_set!(type, message, file: nil, line: nil)
|
||||||
# Don't print annotations during tests, too messy to handle these.
|
# Don't print annotations during tests, too messy to handle these.
|
||||||
return false if ENV.fetch("HOMEBREW_TESTS", false)
|
return false if ENV.fetch("HOMEBREW_TESTS", false)
|
||||||
return false unless env_set?
|
return false unless env_set?
|
||||||
|
|||||||
@ -776,6 +776,6 @@ class Version
|
|||||||
|
|
||||||
sig { params(first: Integer, second: Integer).returns(Integer) }
|
sig { params(first: Integer, second: Integer).returns(Integer) }
|
||||||
def max(first, second)
|
def max(first, second)
|
||||||
(first > second) ? first : second
|
[first, second].max
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -37,6 +37,8 @@ Style/TopLevelMethodDefinition:
|
|||||||
Lint/NonAtomicFileOperation:
|
Lint/NonAtomicFileOperation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# The markdown linter config files don't need to be typed strict.
|
# We're not using Sorbet for the documentation.
|
||||||
Sorbet/StrictSigil:
|
Sorbet/StrictSigil:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Sorbet/BlockMethodDefinition:
|
||||||
|
Enabled: false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user