Merge branch 'master' into install-upgrade-outdated

This commit is contained in:
Connor Mann 2021-06-14 11:16:20 -04:00
commit 4b59636ae8
No known key found for this signature in database
GPG Key ID: 5886083015754F6F
187 changed files with 1117 additions and 651 deletions

View File

@ -24,7 +24,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-
- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet
- name: Install shellcheck
run: brew install shellcheck
@ -60,7 +60,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-
- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet
- run: brew doctor
@ -152,7 +152,7 @@ jobs:
# Can't cache this because we need to check that it doesn't fail the
# "uncommitted RubyGems" step with a cold cache.
- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet
- name: Check for uncommitted RubyGems
run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby
@ -206,7 +206,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-
- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet
- name: Create parallel test log directory
run: mkdir tests
@ -227,7 +227,7 @@ jobs:
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: codecov/codecov-action@a1ed4b322b4b38cb846afb5a0ebfa17086917d27
- uses: codecov/codecov-action@29386c70ef20e286228c72b668a06fd0e8399192
test-default-formula-linux:
name: test default formula (Linux)
@ -265,7 +265,7 @@ jobs:
# Can't cache this because we need to check that it doesn't fail the
# "uncommitted RubyGems" step with a cold cache.
- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet
- name: Check for uncommitted RubyGems
run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby
@ -319,4 +319,4 @@ jobs:
- run: brew test-bot --only-formulae --test-default-formula
- uses: codecov/codecov-action@a1ed4b322b4b38cb846afb5a0ebfa17086917d27
- uses: codecov/codecov-action@29386c70ef20e286228c72b668a06fd0e8399192

View File

@ -2,6 +2,7 @@
BUNDLE_BIN: "false"
BUNDLE_CLEAN: "true"
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_FORGET_CLI_OPTIONS: "true"
BUNDLE_JOBS: "4"
BUNDLE_PATH: "vendor/bundle"
BUNDLE_RETRY: "3"

View File

@ -8,6 +8,7 @@ Style/Documentation:
- "cask/macos.rb"
- "cli/args.rb"
- "cli/parser.rb"
- "default_prefix.rb"
- "global.rb"
- "keg_relocate.rb"
- "os/linux/global.rb"

View File

@ -13,16 +13,19 @@ gem "rspec", require: false
gem "rspec-github", require: false
gem "rspec-its", require: false
gem "rspec-retry", require: false
gem "rspec-sorbet", require: false
gem "rspec-wait", require: false
gem "rubocop", require: false
gem "rubocop-ast", require: false
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
gem "warning", require: false
group :sorbet, optional: true do
gem "rspec-sorbet", require: false
gem "sorbet", require: false
gem "sorbet-runtime", require: false
gem "tapioca", require: false
gem "warning", require: false
end
# vendored gems
gem "activesupport"

View File

@ -109,7 +109,7 @@ GEM
rspec-support (3.10.2)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
rubocop (1.16.0)
rubocop (1.16.1)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
@ -127,7 +127,7 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.3.0)
rubocop-rspec (2.4.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
rubocop-sorbet (0.6.2)

View File

@ -56,6 +56,8 @@ module Cask
caveats = cask.caveats
return if caveats.empty?
Homebrew.messages.record_caveats(cask.token, caveats)
<<~EOS
#{ohai_title "Caveats"}
#{caveats}

View File

@ -275,6 +275,9 @@ module Homebrew
sig { returns(T.nilable(String)) }
def screen_saverdir; end
sig { returns(T.nilable(T::Array[String])) }
def groups; end
end
end
end

View File

@ -10,6 +10,7 @@ require "utils/tty"
COMMAND_DESC_WIDTH = 80
OPTION_DESC_WIDTH = 43
HIDDEN_DESC_PLACEHOLDER = "@@HIDDEN@@"
module Homebrew
module CLI
@ -148,13 +149,13 @@ module Homebrew
end
def switch(*names, description: nil, replacement: nil, env: nil, required_for: nil, depends_on: nil,
method: :on)
method: :on, hidden: false)
global_switch = names.first.is_a?(Symbol)
return if global_switch
description = option_to_description(*names) if description.nil?
description = option_description(description, *names, hidden: hidden)
if replacement.nil?
process_option(*names, description, type: :switch)
process_option(*names, description, type: :switch, hidden: hidden)
else
description += " (disabled#{"; replaced by #{replacement}" if replacement.present?})"
end
@ -198,10 +199,10 @@ module Homebrew
@parser.banner
end
def comma_array(name, description: nil)
def comma_array(name, description: nil, hidden: false)
name = name.chomp "="
description = option_to_description(name) if description.nil?
process_option(name, description, type: :comma_array)
description = option_description(description, name, hidden: hidden)
process_option(name, description, type: :comma_array, hidden: hidden)
@parser.on(name, OptionParser::REQUIRED_ARGUMENT, Array, *wrap_option_desc(description)) do |list|
@args[option_to_name(name)] = list
end
@ -215,7 +216,7 @@ module Homebrew
[OptionParser::OPTIONAL_ARGUMENT, :optional_flag]
end
names.map! { |name| name.chomp "=" }
description = option_to_description(*names) if description.nil?
description = option_description(description, *names, hidden: hidden)
if replacement.nil?
process_option(*names, description, type: flag_type, hidden: hidden)
else
@ -255,6 +256,13 @@ module Homebrew
names.map { |name| name.to_s.sub(/\A--?/, "").tr("-", " ") }.max
end
def option_description(description, *names, hidden: false)
return HIDDEN_DESC_PLACEHOLDER if hidden
return description if description.present?
option_to_description(*names)
end
def parse_remaining(argv, ignore_invalid_options: false)
i = 0
remaining = []
@ -347,6 +355,7 @@ module Homebrew
def generate_help_text
Formatter.wrap(@parser.to_s, COMMAND_DESC_WIDTH)
.gsub(/\n.*?@@HIDDEN@@.*?(?=\n)/, "")
.sub(/^/, "#{Tty.bold}Usage: brew#{Tty.reset} ")
.gsub(/`(.*?)`/m, "#{Tty.bold}\\1#{Tty.reset}")
.gsub(%r{<([^\s]+?://[^\s]+?)>}) { |url| Formatter.url(url) }
@ -597,7 +606,7 @@ module Homebrew
def process_option(*args, type:, hidden: false)
option, = @parser.make_switch(args)
@processed_options.reject! { |existing| existing.second == option.long.first } if option.long.first.present?
@processed_options << [option.short.first, option.long.first, option.arg, option.desc.first]
@processed_options << [option.short.first, option.long.first, option.arg, option.desc.first, hidden]
if type == :switch
disable_switch(*args)
@ -607,6 +616,7 @@ module Homebrew
end
end
return if hidden
return if self.class.global_options.include? [option.short.first, option.long.first, option.desc.first]
@non_global_processed_options << [option.long.first || option.short.first, type]

View File

@ -52,7 +52,8 @@ module Homebrew
"JSON output: <https://docs.brew.sh/Querying-Brew>"
switch "--bottle",
depends_on: "--json",
description: "Output information about the bottles for <formula> and its dependencies."
description: "Output information about the bottles for <formula> and its dependencies.",
hidden: true
switch "--installed",
depends_on: "--json",
description: "Print JSON of formulae that are currently installed."

View File

@ -187,136 +187,15 @@ module Homebrew
raise BuildFlagsError.new(build_flags, bottled: formulae.all?(&:bottled?)) if build_flags.present?
end
installed_formulae = []
formulae.each do |f|
# head-only without --HEAD is an error
if !args.HEAD? && f.stable.nil?
odie <<~EOS
#{f.full_name} is a head-only formula.
To install it, run:
brew install --HEAD #{f.full_name}
EOS
end
# --HEAD, fail with no head defined
odie "No head is defined for #{f.full_name}" if args.HEAD? && f.head.nil?
installed_head_version = f.latest_head_version
if installed_head_version &&
!f.head_version_outdated?(installed_head_version, fetch_head: args.fetch_HEAD?)
new_head_installed = true
end
prefix_installed = f.prefix.exist? && !f.prefix.children.empty?
if f.keg_only? && f.any_version_installed? && f.optlinked? && !args.force?
# keg-only install is only possible when no other version is
# linked to opt, because installing without any warnings can break
# dependencies. Therefore before performing other checks we need to be
# sure --force flag is passed.
if f.outdated?
if Homebrew::EnvConfig.no_install_upgrade?
optlinked_version = Keg.for(f.opt_prefix).version
onoe <<~EOS
#{f.full_name} #{optlinked_version} is already installed.
To upgrade to #{f.version}, run:
brew upgrade #{f.full_name}
EOS
else
installed_formulae << f
end
elsif args.only_dependencies?
installed_formulae << f
elsif !args.quiet?
opoo <<~EOS
#{f.full_name} #{f.pkg_version} is already installed and up-to-date.
To reinstall #{f.pkg_version}, run:
brew reinstall #{f.name}
EOS
end
elsif (args.HEAD? && new_head_installed) || prefix_installed
# After we're sure that --force flag is passed for linked to opt
# keg-only we need to be sure that the version we're attempting to
# install is not already installed.
installed_version = if args.HEAD?
f.latest_head_version
else
f.pkg_version
end
msg = "#{f.full_name} #{installed_version} is already installed"
linked_not_equals_installed = f.linked_version != installed_version
if f.linked? && linked_not_equals_installed
msg = if args.quiet?
nil
else
<<~EOS
#{msg}.
The currently linked version is: #{f.linked_version}
EOS
end
elsif !f.linked? || f.keg_only?
msg = <<~EOS
#{msg}, it's just not linked.
To link this version, run:
brew link #{f}
EOS
elsif args.only_dependencies?
msg = nil
installed_formulae << f
else
msg = if args.quiet?
nil
else
<<~EOS
#{msg} and up-to-date.
To reinstall #{f.pkg_version}, run:
brew reinstall #{f.name}
EOS
end
end
opoo msg if msg
elsif !f.any_version_installed? && (old_formula = f.old_installed_formulae.first)
msg = "#{old_formula.full_name} #{old_formula.any_installed_version} already installed"
msg = if !old_formula.linked? && !old_formula.keg_only?
<<~EOS
#{msg}, it's just not linked.
To link this version, run:
brew link #{old_formula.full_name}
EOS
elsif args.quiet?
nil
else
"#{msg}."
end
opoo msg if msg
elsif f.migration_needed? && !args.force?
# Check if the formula we try to install is the same as installed
# but not migrated one. If --force is passed then install anyway.
opoo <<~EOS
#{f.oldname} is already installed, it's just not migrated.
To migrate this formula, run:
brew migrate #{f}
Or to force-install it, run:
brew install #{f} --force
EOS
else
# If none of the above is true and the formula is linked, then
# FormulaInstaller will handle this case.
installed_formulae << f
end
# Even if we don't install this formula mark it as no longer just
# installed as a dependency.
next unless f.opt_prefix.directory?
keg = Keg.new(f.opt_prefix.resolved_path)
tab = Tab.for_keg(keg)
unless tab.installed_on_request
tab.installed_on_request = true
tab.write
end
installed_formulae = formulae.select do |f|
Install.install_formula?(
f,
head: args.HEAD?,
fetch_head: args.fetch_HEAD?,
only_dependencies: args.only_dependencies?,
force: args.force?,
quiet: args.quiet?,
)
end
return if installed_formulae.empty?
@ -325,7 +204,24 @@ module Homebrew
installed_formulae.each do |f|
Migrator.migrate_if_needed(f, force: args.force?)
install_formula(f, args: args)
Install.install_formula(
f,
build_bottle: args.build_bottle?,
force_bottle: args.force_bottle?,
bottle_arch: args.bottle_arch,
ignore_deps: args.ignore_dependencies?,
only_deps: args.only_dependencies?,
include_test_formulae: args.include_test_formulae,
build_from_source_formulae: args.build_from_source_formulae,
cc: args.cc,
git: args.git?,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?,
)
Cleanup.install_formula_clean!(f)
end
@ -395,65 +291,4 @@ module Homebrew
puts "To install one of them, run (for example):\n brew install #{taps_search_results.first}"
end
end
def install_formula(f, args:)
f.print_tap_action
build_options = f.build
if !Homebrew::EnvConfig.no_install_upgrade? && f.outdated? && !f.head?
formulae = [f, *f.old_installed_formulae]
version_upgrade = "#{f.linked_version} -> #{f.pkg_version}"
oh1 <<~EOS
#{f.name} #{f.linked_version} is installed and out of date
Upgrading #{Formatter.identifier(f.name)} #{version_upgrade}
EOS
outdated_kegs = formulae.map(&:linked_keg)
.select(&:directory?)
.map { |k| Keg.new(k.resolved_path) }
linked_kegs = outdated_kegs.select(&:linked?)
end
fi = FormulaInstaller.new(
f,
**{
options: build_options.used_options,
build_bottle: args.build_bottle?,
force_bottle: args.force_bottle?,
bottle_arch: args.bottle_arch,
ignore_deps: args.ignore_dependencies?,
only_deps: args.only_dependencies?,
include_test_formulae: args.include_test_formulae,
build_from_source_formulae: args.build_from_source_formulae,
cc: args.cc,
git: args.git?,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?,
}.compact,
)
fi.prelude
fi.fetch
outdated_kegs.each(&:unlink) if outdated_kegs.present?
fi.install
fi.finish
rescue FormulaInstallationAlreadyAttemptedError
# We already attempted to install f as part of the dependency tree of
# another formula. In that case, don't generate an error, just move on.
nil
rescue CannotInstallFormulaError => e
ofail e.message
ensure
begin
# Re-link kegs if upgrade fails
linked_kegs.each(&:link) unless formula.latest_version_installed?
rescue
nil
end
end
end

View File

@ -176,9 +176,11 @@ module Commands
return if path.blank?
if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path))
cmd_parser.processed_options.map do |short, long, _, desc|
cmd_parser.processed_options.map do |short, long, _, desc, hidden|
next if hidden
[long || short, desc]
end
end.compact
else
options = []
comment_lines = path.read.lines.grep(/^#:/)

View File

@ -0,0 +1,6 @@
# typed: strict
module EnvVar
sig { params(env: String).returns(String) }
def self.[](env); end
end

View File

@ -0,0 +1,12 @@
# typed: true
# frozen_string_literal: true
module Homebrew
DEFAULT_PREFIX, DEFAULT_REPOSITORY = if OS.mac? && Hardware::CPU.arm?
[HOMEBREW_MACOS_ARM_DEFAULT_PREFIX, HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY]
elsif OS.linux? && !EnvConfig.force_homebrew_on_linux?
[HOMEBREW_LINUX_DEFAULT_PREFIX, HOMEBREW_LINUX_DEFAULT_REPOSITORY]
else
[HOMEBREW_DEFAULT_PREFIX, HOMEBREW_DEFAULT_REPOSITORY]
end.freeze
end

View File

@ -204,6 +204,7 @@ module Homebrew
cask_results = if audit_casks.empty?
{}
else
require "cask/cmd/abstract_command"
require "cask/cmd/audit"
Cask::Cmd::Audit.audit_casks(

View File

@ -172,7 +172,9 @@ module Homebrew
def cmd_parser_manpage_lines(cmd_parser)
lines = [format_usage_banner(cmd_parser.usage_banner_text)]
lines += cmd_parser.processed_options.map do |short, long, _, desc|
lines += cmd_parser.processed_options.map do |short, long, _, desc, hidden|
next if hidden
if long.present?
next if Homebrew::CLI::Parser.global_options.include?([short, long, desc])
next if Homebrew::CLI::Parser.global_cask_options.any? do |_, option, description:, **|
@ -181,7 +183,7 @@ module Homebrew
end
generate_option_doc(short, long, desc)
end.reject(&:blank?)
end.compact
lines
end

View File

@ -15,14 +15,19 @@ module Homebrew
description <<~EOS
Install Homebrew's Bundler gems.
EOS
comma_array "--groups=",
description: "Installs the specified comma-separated list of gem groups (default: last used)."
named_args :none
end
end
def install_bundler_gems
install_bundler_gems_args.parse
args = install_bundler_gems_args.parse
Homebrew.install_bundler_gems!
# Clear previous settings. We want to fully replace - not append.
Homebrew::Settings.delete(:gemgroups) if args.groups
Homebrew.install_bundler_gems!(groups: args.groups || [])
end
end

View File

@ -39,15 +39,17 @@ module Homebrew
def tests
args = tests_args.parse
Homebrew.install_bundler_gems!
Homebrew.install_bundler_gems!(groups: ["sorbet"])
require "byebug" if args.byebug?
HOMEBREW_LIBRARY_PATH.cd do
# Cleanup any unwanted user configuration.
allowed_test_env = [
"HOMEBREW_GITHUB_API_TOKEN",
"HOMEBREW_TEMP",
allowed_test_env = %w[
HOMEBREW_GITHUB_API_TOKEN
HOMEBREW_CACHE
HOMEBREW_LOGS
HOMEBREW_TEMP
]
Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env|
next if allowed_test_env.include?(env)

View File

@ -51,7 +51,7 @@ module Homebrew
args = typecheck_args.parse
Homebrew.install_bundler_gems!
Homebrew.install_bundler_gems!(groups: ["sorbet"])
HOMEBREW_LIBRARY_PATH.cd do
if args.update?

View File

@ -158,10 +158,6 @@ module Homebrew
formulae.each do |f|
name = f.name.downcase
if f.bottle_specification.tag?(@bottle_tag, no_older_versions: true)
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: already bottled" if any_named_args
next
end
if f.disabled?
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: formula disabled" if any_named_args
@ -190,11 +186,7 @@ module Homebrew
Version.new(MacOS::Xcode.latest_version(macos: macos_version)) >= r.version
when ArchRequirement
arch = r.arch
arch = :intel if arch == :x86_64
arch = :arm64 if arch == :arm
arch == macos_version.arch
r.arch == @bottle_tag.arch
else
true
end
@ -215,6 +207,11 @@ module Homebrew
next
end
if f.bottle_specification.tag?(@bottle_tag, no_older_versions: true)
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: already bottled" if any_named_args
next
end
deps = Array(deps_hash[f.name]).reject do |dep|
dep.bottle_specification.tag?(@bottle_tag, no_older_versions: true) || dep.bottle_unneeded?
end

View File

@ -29,6 +29,8 @@ module Homebrew
Homebrew.install_bundler!
ENV["BUNDLE_WITH"] = "sorbet"
ohai "cd #{HOMEBREW_LIBRARY_PATH}"
HOMEBREW_LIBRARY_PATH.cd do
if args.update

View File

@ -149,7 +149,9 @@ module Homebrew
def broken_tap(tap)
return unless Utils::Git.available?
return unless HOMEBREW_REPOSITORY.git?
repo = HOMEBREW_REPOSITORY.dup.extend(GitRepositoryExtension)
return unless repo.git?
message = <<~EOS
#{tap.full_name} was not tapped properly! Run:
@ -161,7 +163,7 @@ module Homebrew
tap_head = tap.git_head
return message if tap_head.blank?
return if tap_head != HOMEBREW_REPOSITORY.git_head
return if tap_head != repo.git_head
message
end
@ -574,7 +576,8 @@ module Homebrew
end
def check_brew_git_origin
examine_git_origin(HOMEBREW_REPOSITORY, Homebrew::EnvConfig.brew_git_remote)
repo = HOMEBREW_REPOSITORY.dup.extend(GitRepositoryExtension)
examine_git_origin(repo, Homebrew::EnvConfig.brew_git_remote)
end
def check_coretap_integrity

View File

@ -651,6 +651,7 @@ end
class LocalBottleDownloadStrategy < AbstractFileDownloadStrategy
def initialize(path) # rubocop:disable Lint/MissingSuper
@cached_location = path
extend Pourable
end
end

View File

@ -159,13 +159,16 @@ class Keg
brewed_perl = runtime_dependencies&.any? { |dep| dep["full_name"] == "perl" && dep["declared_directly"] }
perl_path = if brewed_perl || name == "perl"
"#{HOMEBREW_PREFIX}/opt/perl/bin/perl"
elsif tab["built_on"].present?
perl_path = "/usr/bin/perl#{tab["built_on"]["preferred_perl"]}"
# For `:all` bottles, we could have built this bottle with a Perl we don't have.
# Such bottles typically don't have strict version requirements.
perl_path = "/usr/bin/perl#{MacOS.preferred_perl_version}" unless File.exist?(perl_path)
perl_path
else
perl_version = if tab["built_on"].present?
tab["built_on"]["preferred_perl"]
else
MacOS.preferred_perl_version
end
"/usr/bin/perl#{perl_version}"
"/usr/bin/perl#{MacOS.preferred_perl_version}"
end
relocation.add_replacement_pair(:perl, PERL_PLACEHOLDER, perl_path)

View File

@ -1919,17 +1919,19 @@ class Formula
[tag.to_s, info]
end.to_h
return bottles unless top_level
hash = {
"name" => name,
"pkg_version" => pkg_version,
"rebuild" => bottle["rebuild"],
"bottles" => bottles,
}
dependencies = declared_runtime_dependencies.map do |dep|
return hash unless top_level
hash["dependencies"] = declared_runtime_dependencies.map do |dep|
dep.to_formula.to_recursive_bottle_hash(top_level: false)
end
{
"name" => name,
"bottles" => bottles,
"dependencies" => dependencies,
}
hash
end
# Returns the bottle information for a formula

View File

@ -404,7 +404,7 @@ class FormulaInstaller
options = display_options(formula).join(" ")
oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header?
unless formula.tap&.private?
if formula.tap&.installed? && !formula.tap&.private?
action = "#{formula.full_name} #{options}".strip
Utils::Analytics.report_event("install", action)
@ -769,7 +769,7 @@ class FormulaInstaller
@show_summary_heading = true
ohai "Caveats", caveats.to_s
Homebrew.messages.record_caveats(formula, caveats)
Homebrew.messages.record_caveats(formula.name, caveats)
end
sig { void }
@ -1074,9 +1074,14 @@ class FormulaInstaller
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
--
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
#{formula.path}
]
args << if formula.local_bottle_path.present?
formula.prefix/".brew/#{formula.name}.rb"
else
formula.path
end
Utils.safe_fork do
if Sandbox.available?
sandbox = Sandbox.new
@ -1163,7 +1168,7 @@ class FormulaInstaller
tab.source["versions"]["stable"] = formula.stable.version.to_s
tab.source["versions"]["version_scheme"] = formula.version_scheme
tab.source["path"] = formula.specified_path.to_s
tab.source["tap_git_head"] = formula.tap&.git_head
tab.source["tap_git_head"] = formula.tap&.installed? ? formula.tap&.git_head : nil
tab.tap = formula.tap
tab.write

View File

@ -1,22 +1,16 @@
# typed: false
# frozen_string_literal: true
require_relative "load_path"
require_relative "startup"
require "English"
require "fileutils"
require "json"
require "json/add/exception"
require "pathname"
require "ostruct"
require "pp"
require "forwardable"
require "rbconfig"
RUBY_PATH = Pathname.new(RbConfig.ruby).freeze
RUBY_BIN = RUBY_PATH.dirname.freeze
# Only require "core_ext" here to ensure we're only requiring the minimum of
# what we need.
require "active_support/core_ext/object/blank"
@ -72,27 +66,15 @@ HOMEBREW_PULL_OR_COMMIT_URL_REGEX =
%r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})].freeze
HOMEBREW_BOTTLES_EXTNAME_REGEX = /\.([a-z0-9_]+)\.bottle\.(?:(\d+)\.)?tar\.gz$/.freeze
require "utils/sorbet"
require "env_config"
require "compat/early" unless Homebrew::EnvConfig.no_compat?
require "os"
require "messages"
require "default_prefix"
module Homebrew
extend FileUtils
remove_const :DEFAULT_PREFIX if defined?(DEFAULT_PREFIX)
remove_const :DEFAULT_REPOSITORY if defined?(DEFAULT_REPOSITORY)
DEFAULT_PREFIX, DEFAULT_REPOSITORY = if OS.mac? && Hardware::CPU.arm?
[HOMEBREW_MACOS_ARM_DEFAULT_PREFIX, HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY]
elsif OS.linux? && !EnvConfig.force_homebrew_on_linux?
[HOMEBREW_LINUX_DEFAULT_PREFIX, HOMEBREW_LINUX_DEFAULT_REPOSITORY]
else
[HOMEBREW_DEFAULT_PREFIX, HOMEBREW_DEFAULT_REPOSITORY]
end.freeze
DEFAULT_CELLAR = "#{DEFAULT_PREFIX}/Cellar"
DEFAULT_MACOS_CELLAR = "#{HOMEBREW_DEFAULT_PREFIX}/Cellar"
DEFAULT_MACOS_ARM_CELLAR = "#{HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}/Cellar"
@ -124,8 +106,8 @@ module Homebrew
end
end
require "config"
require "context"
require "extend/git_repository"
require "extend/pathname"
require "extend/predicable"
require "extend/module"

View File

@ -90,6 +90,213 @@ module Homebrew
EOS
end
private_class_method :check_cc_argv
def install_formula?(
f,
head: false,
fetch_head: false,
only_dependencies: false,
force: false,
quiet: false
)
# head-only without --HEAD is an error
if !head && f.stable.nil?
odie <<~EOS
#{f.full_name} is a head-only formula.
To install it, run:
brew install --HEAD #{f.full_name}
EOS
end
# --HEAD, fail with no head defined
odie "No head is defined for #{f.full_name}" if head && f.head.nil?
installed_head_version = f.latest_head_version
if installed_head_version &&
!f.head_version_outdated?(installed_head_version, fetch_head: fetch_head)
new_head_installed = true
end
prefix_installed = f.prefix.exist? && !f.prefix.children.empty?
if f.keg_only? && f.any_version_installed? && f.optlinked? && !force
# keg-only install is only possible when no other version is
# linked to opt, because installing without any warnings can break
# dependencies. Therefore before performing other checks we need to be
# sure --force flag is passed.
if f.outdated?
return true unless Homebrew::EnvConfig.no_install_upgrade?
optlinked_version = Keg.for(f.opt_prefix).version
onoe <<~EOS
#{f.full_name} #{optlinked_version} is already installed.
To upgrade to #{f.version}, run:
brew upgrade #{f.full_name}
EOS
elsif only_dependencies
return true
elsif !quiet
opoo <<~EOS
#{f.full_name} #{f.pkg_version} is already installed and up-to-date.
To reinstall #{f.pkg_version}, run:
brew reinstall #{f.name}
EOS
end
elsif (head && new_head_installed) || prefix_installed
# After we're sure that --force flag is passed for linked to opt
# keg-only we need to be sure that the version we're attempting to
# install is not already installed.
installed_version = if head
f.latest_head_version
else
f.pkg_version
end
msg = "#{f.full_name} #{installed_version} is already installed"
linked_not_equals_installed = f.linked_version != installed_version
if f.linked? && linked_not_equals_installed
msg = if quiet
nil
else
<<~EOS
#{msg}.
The currently linked version is: #{f.linked_version}
EOS
end
elsif !f.linked? || f.keg_only?
msg = <<~EOS
#{msg}, it's just not linked.
To link this version, run:
brew link #{f}
EOS
elsif only_dependencies
msg = nil
return true
else
msg = if quiet
nil
else
<<~EOS
#{msg} and up-to-date.
To reinstall #{f.pkg_version}, run:
brew reinstall #{f.name}
EOS
end
end
opoo msg if msg
elsif !f.any_version_installed? && (old_formula = f.old_installed_formulae.first)
msg = "#{old_formula.full_name} #{old_formula.any_installed_version} already installed"
msg = if !old_formula.linked? && !old_formula.keg_only?
<<~EOS
#{msg}, it's just not linked.
To link this version, run:
brew link #{old_formula.full_name}
EOS
elsif quiet
nil
else
"#{msg}."
end
opoo msg if msg
elsif f.migration_needed? && !force
# Check if the formula we try to install is the same as installed
# but not migrated one. If --force is passed then install anyway.
opoo <<~EOS
#{f.oldname} is already installed, it's just not migrated.
To migrate this formula, run:
brew migrate #{f}
Or to force-install it, run:
brew install #{f} --force
EOS
else
# If none of the above is true and the formula is linked, then
# FormulaInstaller will handle this case.
return true
end
# Even if we don't install this formula mark it as no longer just
# installed as a dependency.
return false unless f.opt_prefix.directory?
keg = Keg.new(f.opt_prefix.resolved_path)
tab = Tab.for_keg(keg)
unless tab.installed_on_request
tab.installed_on_request = true
tab.write
end
false
end
def install_formula(
f,
build_bottle: false,
force_bottle: false,
bottle_arch: nil,
ignore_deps: false,
only_deps: false,
include_test_formulae: [],
build_from_source_formulae: [],
cc: nil,
git: false,
interactive: false,
keep_tmp: false,
force: false,
debug: false,
quiet: false,
verbose: false
)
f.print_tap_action
build_options = f.build
if !Homebrew::EnvConfig.no_install_upgrade? && f.outdated? && !f.head?
outdated_formulae = [f, *f.old_installed_formulae]
version_upgrade = "#{f.linked_version} -> #{f.pkg_version}"
oh1 <<~EOS
#{f.name} #{f.linked_version} is installed and outdated
Upgrading #{Formatted.identifier(f.name)} #{version_upgrade}
EOS
outdated_kegs = outdated_formulae.map(&:linked_keg).select(&:directory?).map { |k| Keg.new(k.resolved_path) }
linked_kegs = outdated_kegs.select(&:linked)
end
fi = FormulaInstaller.new(
f,
options: build_options.used_options,
build_bottle: build_bottle,
force_bottle: force_bottle,
bottle_arch: bottle_arch,
ignore_deps: ignore_deps,
only_deps: only_deps,
include_test_formulae: include_test_formulae,
build_from_source_formulae: build_from_source_formulae,
cc: cc,
git: git,
interactive: interactive,
keep_tmp: keep_tmp,
force: force,
debug: debug,
quiet: quiet,
verbose: verbose,
)
fi.prelude
fi.fetch
outdated_kegs.each(&:unlink) if outdated_kegs.present?
fi.install
fi.finish
rescue FormulaInstallationAlreadyAttemptedError
# We already attempted to install f as part of the dependency tree of
# another formula. In that case, don't generate an error, just move on.
nil
rescue CannotInstallFormulaError => e
ofail e.message
ensure
# Re-link kegs if upgrade fails
linked_kegs.each(&:link) unless f.latest_version_installed?
end
end
end

View File

@ -15,8 +15,8 @@ class Messages
@install_times = []
end
def record_caveats(f, caveats)
@caveats.push(formula: f.name, caveats: caveats)
def record_caveats(package, caveats)
@caveats.push(package: package, caveats: caveats)
end
def formula_installed(f, elapsed_time)
@ -36,7 +36,7 @@ class Messages
oh1 "Caveats"
@caveats.each do |c|
ohai c[:formula], c[:caveats]
ohai c[:package], c[:caveats]
end
end

View File

@ -0,0 +1,12 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: expat
Version: 2.2.8
Description: expat XML parser
URL: http://www.libexpat.org
Libs: -L${libdir} -lexpat
Cflags:

View File

@ -0,0 +1,40 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 2001 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.haxx.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
###########################################################################
# This should most probably benefit from getting a "Requires:" field added
# dynamically by configure.
#
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
supported_protocols="DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP"
supported_features="AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO MultiSSL NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy"
Name: libcurl
URL: https://curl.haxx.se/
Description: Library to transfer files with ftp, http, etc.
Version: 7.64.1
Libs: -L${libdir} -lcurl
Libs.private: -lldap -lz
Cflags:

View File

@ -0,0 +1,12 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libedit
Description: command line editor library provides generic line editing, history, and tokenization functions.
Version: 3.0
Requires:
Libs: -L${libdir} -ledit
Cflags: -I${includedir}/editline

View File

@ -0,0 +1,13 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libexslt
Version: 0.8.17
Description: EXSLT Extension library
Requires: libxml-2.0
Libs: -L${libdir} -lexslt -lxslt -lxml2 -lz -lpthread -licucore -lm
Cflags:

View File

@ -0,0 +1,12 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
toolexeclibdir=${libdir}
includedir=${prefix}/include/ffi
Name: libffi
Description: Library supporting Foreign Function Interfaces
Version: 3.3-rc0
Libs: -L${toolexeclibdir} -lffi
Cflags: -I${includedir}

View File

@ -0,0 +1,14 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
modules=1
Name: libXML
Version: 2.9.4
Description: libXML library version2.
Requires:
Libs: -L${libdir} -lxml2
Libs.private: -lz -lpthread -licucore -lm
Cflags:

View File

@ -0,0 +1,13 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libxslt
Version: 1.1.29
Description: XSLT library version 2.
Requires: libxml-2.0
Libs: -L${libdir} -lxslt -lxml2 -lz -lpthread -licucore -lm
Cflags:

View File

@ -0,0 +1,14 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
major_version=5
version=5.7.20081102
Name: ncurses
Description: ncurses 5.7 library
Version: ${version}
Requires:
Libs: -L${libdir} -lncurses
Cflags:

View File

@ -0,0 +1,14 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
major_version=5
version=5.7.20081102
Name: ncursesw
Description: ncurses 5.7 library
Version: ${version}
Requires:
Libs: -L${libdir} -lncurses
Cflags:

View File

@ -0,0 +1,12 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: SQLite
Description: SQL database engine
Version: 3.32.3
Libs: -L${libdir} -lsqlite3
Libs.private:
Cflags:

View File

@ -0,0 +1,14 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
sharedlibdir=${libdir}
includedir=${prefix}/include/uuid
Name: uuid
Description: Universally unique id library
Version: 1.0
Requires:
Libs:
Cflags: -I${includedir}

View File

@ -0,0 +1,14 @@
homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
sharedlibdir=${libdir}
includedir=${prefix}/include
Name: zlib
Description: zlib compression library
Version: 1.2.11
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags:

View File

@ -22,6 +22,7 @@ module OS
def latest_version(macos: MacOS.version)
latest_stable = "12.5"
case macos
when "12" then "13.0"
when "11" then latest_stable
when "10.15" then "12.4"
when "10.14" then "11.3.1"
@ -45,6 +46,7 @@ module OS
sig { returns(String) }
def minimum_version
case MacOS.version
when "12" then "13.0"
when "11" then "12.2"
when "10.15" then "11.0"
when "10.14" then "10.2"
@ -224,6 +226,7 @@ module OS
when "11.0.0" then "11.3.1"
when "11.0.3" then "11.7"
when "12.0.0" then "12.4"
when "13.0.0" then "13.0"
else "12.5"
end
end
@ -314,6 +317,7 @@ module OS
sig { returns(String) }
def latest_clang_version
case MacOS.version
when "12" then "1300.0.18.6"
when "11" then "1205.0.22.9"
when "10.15" then "1200.0.32.29"
when "10.14" then "1100.0.33.17"
@ -331,6 +335,7 @@ module OS
sig { returns(String) }
def minimum_version
case MacOS.version
when "12" then "13.0.0"
when "11" then "12.0.0"
when "10.15" then "11.0.0"
when "10.14" then "10.0.0"

View File

@ -1,40 +1,6 @@
# typed: strict
# frozen_string_literal: true
require_relative "load_path"
require_relative "standalone"
require "active_support/core_ext/array/conversions"
require "utils/sorbet"
require "rubocop-performance"
require "rubocop-rails"
require "rubocop-rspec"
require "rubocop-sorbet"
require "rubocops/io_read"
require "rubocops/shell_commands"
require "rubocops/formula_desc"
require "rubocops/components_order"
require "rubocops/components_redundancy"
require "rubocops/dependency_order"
require "rubocops/homepage"
require "rubocops/text"
require "rubocops/caveats"
require "rubocops/checksum"
require "rubocops/patches"
require "rubocops/conflicts"
require "rubocops/options"
require "rubocops/urls"
require "rubocops/lines"
require "rubocops/livecheck"
require "rubocops/class"
require "rubocops/uses_from_macos"
require "rubocops/files"
require "rubocops/keg_only"
require "rubocops/version"
require "rubocops/deprecate_disable"
require "rubocops/bottle"
require "rubocops/rubocop-cask"
require "rubocops/all"

View File

@ -0,0 +1,36 @@
# typed: strict
# frozen_string_literal: true
require "active_support/core_ext/array/conversions"
require "rubocop-performance"
require "rubocop-rails"
require "rubocop-rspec"
require "rubocop-sorbet"
require_relative "io_read"
require_relative "shell_commands"
require_relative "formula_desc"
require_relative "components_order"
require_relative "components_redundancy"
require_relative "dependency_order"
require_relative "homepage"
require_relative "text"
require_relative "caveats"
require_relative "checksum"
require_relative "patches"
require_relative "conflicts"
require_relative "options"
require_relative "urls"
require_relative "lines"
require_relative "livecheck"
require_relative "class"
require_relative "uses_from_macos"
require_relative "files"
require_relative "keg_only"
require_relative "version"
require_relative "deprecate_disable"
require_relative "bottle"
require_relative "rubocop-cask"

View File

@ -3,17 +3,17 @@
require "rubocop"
require "rubocops/cask/constants/stanza"
require_relative "cask/constants/stanza"
require "rubocops/cask/ast/stanza"
require "rubocops/cask/ast/cask_header"
require "rubocops/cask/ast/cask_block"
require "rubocops/cask/extend/string"
require "rubocops/cask/extend/node"
require "rubocops/cask/mixin/cask_help"
require "rubocops/cask/mixin/on_homepage_stanza"
require "rubocops/cask/desc"
require "rubocops/cask/homepage_url_trailing_slash"
require "rubocops/cask/no_dsl_version"
require "rubocops/cask/stanza_order"
require "rubocops/cask/stanza_grouping"
require_relative "cask/ast/stanza"
require_relative "cask/ast/cask_header"
require_relative "cask/ast/cask_block"
require_relative "cask/extend/string"
require_relative "cask/extend/node"
require_relative "cask/mixin/cask_help"
require_relative "cask/mixin/on_homepage_stanza"
require_relative "cask/desc"
require_relative "cask/homepage_url_trailing_slash"
require_relative "cask/no_dsl_version"
require_relative "cask/stanza_order"
require_relative "cask/stanza_grouping"

View File

@ -1,26 +1,25 @@
# typed: true
# frozen_string_literal: true
require "system_command"
require "utils/popen"
module Homebrew
# Helper functions for reading and writing settings.
#
# @api private
module Settings
extend T::Sig
include SystemCommand::Mixin
module_function
sig { params(setting: T.any(String, Symbol), repo: Pathname).returns(T.nilable(String)) }
def read(setting, repo: HOMEBREW_REPOSITORY)
return unless (repo/".git/config").exist?
system_command("git", args: ["config", "--get", "homebrew.#{setting}"], chdir: repo).stdout.chomp.presence
value = Utils.popen_read("git", "-C", repo.to_s, "config", "--get", "homebrew.#{setting}").chomp
return if value.strip.empty?
value
end
sig { params(setting: T.any(String, Symbol), value: T.any(String, T::Boolean), repo: Pathname).void }
def write(setting, value, repo: HOMEBREW_REPOSITORY)
return unless (repo/".git/config").exist?
@ -28,16 +27,15 @@ module Homebrew
return if read(setting, repo: repo) == value
system_command! "git", args: ["config", "--replace-all", "homebrew.#{setting}", value], chdir: repo
Kernel.system("git", "-C", repo.to_s, "config", "--replace-all", "homebrew.#{setting}", value, exception: true)
end
sig { params(setting: T.any(String, Symbol), repo: Pathname).void }
def delete(setting, repo: HOMEBREW_REPOSITORY)
return unless (repo/".git/config").exist?
return if read(setting, repo: repo).blank?
system_command! "git", args: ["config", "--unset-all", "homebrew.#{setting}"], chdir: repo
Kernel.system("git", "-C", repo.to_s, "config", "--unset-all", "homebrew.#{setting}", exception: true)
end
end
end

View File

@ -3,5 +3,14 @@
module Homebrew
module Settings
include Kernel
sig { params(setting: T.any(String, Symbol), repo: Pathname).returns(T.nilable(String)) }
def read(setting, repo: HOMEBREW_REPOSITORY); end
sig { params(setting: T.any(String, Symbol), value: T.any(String, T::Boolean), repo: Pathname).void }
def write(setting, value, repo: HOMEBREW_REPOSITORY); end
sig { params(setting: T.any(String, Symbol), repo: Pathname).void }
def delete(setting, repo: HOMEBREW_REPOSITORY); end
end
end

View File

@ -10044,6 +10044,7 @@ class RuboCop::Cop::Style::QuotedSymbols < ::RuboCop::Cop::Base
def alternative_style; end
def autocorrect(corrector, node); end
def correct_quotes(str); end
def hash_colon_key?(node); end
def quoted?(sym_node); end
def style; end
def wrong_quotes?(node); end
@ -10452,15 +10453,19 @@ class RuboCop::Cop::Style::RedundantSelf < ::RuboCop::Cop::Base
def on_blockarg(node); end
def on_def(node); end
def on_defs(node); end
def on_if(node); end
def on_lvasgn(node); end
def on_masgn(node); end
def on_op_asgn(node); end
def on_or_asgn(node); end
def on_send(node); end
def on_until(node); end
def on_while(node); end
private
def add_lhs_to_local_variables_scopes(rhs, lhs); end
def add_masgn_lhs_variables(rhs, lhs); end
def add_scope(node, local_variables = T.unsafe(nil)); end
def allow_self(node); end
def allowed_send_node?(node); end

View File

@ -6991,11 +6991,6 @@ class Enumerator::Generator
def initialize(*_); end
end
module EnvVar
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Errno::EAUTH
Errno = ::T.let(nil, ::T.untyped)
end
@ -8392,11 +8387,6 @@ class Homebrew::Service
extend ::T::Private::Methods::SingletonMethodHooks
end
module Homebrew::Settings
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Homebrew::Style::LineLocation
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
@ -12636,8 +12626,8 @@ end
class Object
include ::Minitest::Expectations
include ::ActiveSupport::Tryable
include ::SystemCommand::Mixin
include ::Utils::Curl
include ::SystemCommand::Mixin
include ::ActiveSupport::Dependencies::Loadable
include ::ActiveSupport::ForkTracker::CoreExtPrivate
include ::ActiveSupport::ForkTracker::CoreExt
@ -12662,6 +12652,7 @@ class Object
DEPRECATED_OFFICIAL_TAPS = ::T.let(nil, ::T.untyped)
ENV = ::T.let(nil, ::T.untyped)
FORMULA_COMPONENT_PRECEDENCE_LIST = ::T.let(nil, ::T.untyped)
HIDDEN_DESC_PLACEHOLDER = ::T.let(nil, ::T.untyped)
HOMEBREW_BOTTLES_EXTNAME_REGEX = ::T.let(nil, ::T.untyped)
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ::T.let(nil, ::T.untyped)
HOMEBREW_BREW_DEFAULT_GIT_REMOTE = ::T.let(nil, ::T.untyped)
@ -26802,6 +26793,7 @@ end
module RuboCop::AST::NodePattern::Sets
SET_BUILD_RECOMMENDED_TEST_OPTIONAL = ::T.let(nil, ::T.untyped)
SET_DEPENDS_ON_USES_FROM_MACOS = ::T.let(nil, ::T.untyped)
SET_EQL_EQ_BE = ::T.let(nil, ::T.untyped)
SET_INCLUDE_WITH_WITHOUT = ::T.let(nil, ::T.untyped)
SET_SYSTEM_SHELL_OUTPUT_PIPE_OUTPUT = ::T.let(nil, ::T.untyped)
SET_WITH_WITHOUT = ::T.let(nil, ::T.untyped)

View File

@ -0,0 +1,7 @@
# typed: true
# frozen_string_literal: true
# This file should be the first `require` in all entrypoints outside the `brew` environment.
require_relative "standalone/load_path"
require_relative "standalone/sorbet"

View File

@ -3,13 +3,13 @@
require "pathname"
HOMEBREW_LIBRARY_PATH = Pathname(__dir__).realpath.freeze
HOMEBREW_LIBRARY_PATH = Pathname(__dir__).parent.realpath.freeze
require_relative "utils/gems"
require_relative "../utils/gems"
Homebrew.setup_gem_environment!(setup_path: false)
$LOAD_PATH.push HOMEBREW_LIBRARY_PATH.to_s unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
require_relative "vendor/bundle/bundler/setup"
require_relative "../vendor/bundle/bundler/setup"
$LOAD_PATH.uniq!
# Block any gem loading by bypassing rubygem's `require`.
@ -21,5 +21,3 @@ if Kernel.private_method_defined?(:gem_original_require)
Kernel.send(:define_method, :require, Kernel.instance_method(:gem_original_require))
Kernel.send(:private, :require)
end
require_relative "homebrew_bootsnap"

View File

@ -0,0 +1,11 @@
# typed: true
# frozen_string_literal: true
# Explicitly prevent `sorbet-runtime` from being loaded.
def gem(name, *)
raise Gem::LoadError if name == "sorbet-runtime"
super
end
require "sorbet-runtime-stub"

View File

@ -0,0 +1,10 @@
# typed: true
# frozen_string_literal: true
# This file should be the first `require` in all entrypoints of `brew`.
require_relative "standalone/load_path"
require_relative "startup/ruby_path"
require "startup/config"
require_relative "startup/bootsnap"
require_relative "startup/sorbet"

View File

@ -12,9 +12,6 @@ class MissingEnvironmentVariables < RuntimeError; end
#
# @api private
module EnvVar
extend T::Sig
sig { params(env: String).returns(String) }
def self.[](env)
raise MissingEnvironmentVariables, "#{env} was not exported!" unless ENV[env]
@ -22,15 +19,11 @@ module EnvVar
end
end
require "extend/git_repository"
# Where we link under
HOMEBREW_PREFIX = Pathname(EnvVar["HOMEBREW_PREFIX"]).freeze
# Where `.git` is found
HOMEBREW_REPOSITORY = Pathname(EnvVar["HOMEBREW_REPOSITORY"])
.extend(GitRepositoryExtension)
.freeze
HOMEBREW_REPOSITORY = Pathname(EnvVar["HOMEBREW_REPOSITORY"]).freeze
# Where we store most of Homebrew, taps, and various metadata
HOMEBREW_LIBRARY = Pathname(EnvVar["HOMEBREW_LIBRARY"]).freeze

View File

@ -0,0 +1,7 @@
# typed: true
# frozen_string_literal: true
require "rbconfig"
RUBY_PATH = Pathname.new(RbConfig.ruby).freeze
RUBY_BIN = RUBY_PATH.dirname.freeze

View File

@ -0,0 +1,10 @@
# typed: true
# frozen_string_literal: true
if ENV["HOMEBREW_SORBET_RUNTIME"]
# This is only supported under the brew environment.
Homebrew.install_bundler_gems!(groups: ["sorbet"])
require "sorbet-runtime"
else
require "standalone/sorbet"
end

View File

@ -85,7 +85,7 @@ module Homebrew
require "rubocop"
end
require "rubocops"
require "rubocops/all"
args = %w[
--force-exclusion

View File

@ -32,19 +32,24 @@ module SystemConfig
end
end
sig { returns(Pathname) }
def homebrew_repo
HOMEBREW_REPOSITORY.dup.extend(GitRepositoryExtension)
end
sig { returns(String) }
def head
HOMEBREW_REPOSITORY.git_head || "(none)"
homebrew_repo.git_head || "(none)"
end
sig { returns(String) }
def last_commit
HOMEBREW_REPOSITORY.git_last_commit || "never"
homebrew_repo.git_last_commit || "never"
end
sig { returns(String) }
def origin
HOMEBREW_REPOSITORY.git_origin || "(none)"
homebrew_repo.git_origin || "(none)"
end
sig { returns(String) }

View File

@ -1,8 +1,6 @@
# typed: true
# frozen_string_literal: true
require "config"
# Match taps' formulae, e.g. `someuser/sometap/someformula`
HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}.freeze
# Match taps' casks, e.g. `someuser/sometap/somecask`

View File

@ -9,6 +9,7 @@ describe Homebrew::CLI::Parser do
described_class.new do
switch "--more-verbose", description: "Flag for higher verbosity"
switch "--pry", env: :pry
switch "--hidden", hidden: true
end
}
@ -98,6 +99,11 @@ describe Homebrew::CLI::Parser do
expect(args.more_verbose?).to be false
end
it "sets the correct value for a hidden switch" do
args = parser.parse([])
expect(args.hidden?).to be false
end
it "raises an exception and outputs help text when an invalid option is passed" do
expect { parser.parse(["--random"]) }.to raise_error(OptionParser::InvalidOption, /--random/)
.and output(/Usage: brew/).to_stderr
@ -114,6 +120,8 @@ describe Homebrew::CLI::Parser do
described_class.new do
flag "--filename=", description: "Name of the file"
comma_array "--files", description: "Comma separated filenames"
flag "--hidden=", hidden: true
comma_array "--hidden-array", hidden: true
end
}
@ -130,6 +138,12 @@ describe Homebrew::CLI::Parser do
args = parser.parse(["--files=random1.txt,random2.txt"])
expect(args.files).to eq %w[random1.txt random2.txt]
end
it "sets the correct value for hidden flags" do
args = parser.parse(["--hidden=foo", "--hidden-array=bar,baz"])
expect(args.hidden).to eq "foo"
expect(args.hidden_array).to eq %w[bar baz]
end
end
describe "test short flag options" do
@ -361,6 +375,13 @@ describe Homebrew::CLI::Parser do
expect(parser.generate_help_text).to match(/\[--foo=\]/)
end
it "does not include hidden options" do
parser = described_class.new do
switch "--foo", hidden: true
end
expect(parser.generate_help_text).not_to match(/\[--foo\]/)
end
it "doesn't include `[options]` if non non-global options are available" do
parser = described_class.new
expect(parser.generate_help_text).not_to match(/\[options\]/)

View File

@ -2,7 +2,6 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
require "support/lib/config"
describe "brew home" do
let(:testballhome_homepage) {

View File

@ -17,7 +17,9 @@ describe PkgVersion do
specify "#==" do
expect(described_class.parse("1.0_0")).to be == described_class.parse("1.0")
expect(described_class.parse("1.0_1")).to be == described_class.parse("1.0_1")
version_to_compare = described_class.parse("1.0_1")
expect(version_to_compare == described_class.parse("1.0_1")).to be true
expect(version_to_compare == described_class.parse("1.0_2")).to be false
end
describe "#>" do

View File

@ -0,0 +1,8 @@
# typed: true
# frozen_string_literal: true
module Homebrew
# For testing's sake always assume the default prefix
DEFAULT_PREFIX = HOMEBREW_PREFIX.to_s.freeze
DEFAULT_REPOSITORY = HOMEBREW_REPOSITORY.to_s.freeze
end

View File

@ -3,8 +3,6 @@
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
require "pathname"
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]).freeze
TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") do |k|
@ -23,11 +21,9 @@ HOMEBREW_SHIMS_PATH = (HOMEBREW_LIBRARY_PATH/"shims").freeze
# Where external data that has been incorporated into Homebrew is stored
HOMEBREW_DATA_PATH = (HOMEBREW_LIBRARY_PATH/"data").freeze
require "extend/git_repository"
# Paths redirected to a temporary directory and wiped at the end of the test run
HOMEBREW_PREFIX = (Pathname(TEST_TMPDIR)/"prefix").freeze
HOMEBREW_REPOSITORY = HOMEBREW_PREFIX.dup.extend(GitRepositoryExtension).freeze
HOMEBREW_REPOSITORY = HOMEBREW_PREFIX.dup.freeze
HOMEBREW_LIBRARY = (HOMEBREW_REPOSITORY/"Library").freeze
HOMEBREW_CACHE = (HOMEBREW_PREFIX.parent/"cache").freeze
HOMEBREW_CACHE_FORMULA = (HOMEBREW_PREFIX.parent/"formula_cache").freeze
@ -52,12 +48,3 @@ PATCH_B_SHA256 = "57958271bb802a59452d0816e0670d16c8b70bdf6530bcf6f78726489ad89b
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
# For testing's sake always assume the default prefix
module Homebrew
remove_const :DEFAULT_PREFIX if defined?(DEFAULT_PREFIX)
DEFAULT_PREFIX = HOMEBREW_PREFIX.to_s.freeze
remove_const :DEFAULT_REPOSITORY if defined?(DEFAULT_REPOSITORY)
DEFAULT_REPOSITORY = HOMEBREW_REPOSITORY.to_s.freeze
end

View File

@ -52,7 +52,7 @@ module Homebrew
def setup_gem_environment!(gem_home: nil, gem_bindir: nil, setup_path: true)
# Match where our bundler gems are.
gem_home ||= "#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/vendor/bundle/ruby/#{RbConfig::CONFIG["ruby_version"]}"
gem_home ||= "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/ruby/#{RbConfig::CONFIG["ruby_version"]}"
Gem.paths = {
"GEM_HOME" => gem_home,
"GEM_PATH" => gem_home,
@ -128,23 +128,34 @@ module Homebrew
)
end
def install_bundler_gems!(only_warn_on_failure: false, setup_path: true)
def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups: [])
old_path = ENV["PATH"]
old_gem_path = ENV["GEM_PATH"]
old_gem_home = ENV["GEM_HOME"]
old_bundle_gemfile = ENV["BUNDLE_GEMFILE"]
old_bundle_with = ENV["BUNDLE_WITH"]
install_bundler!
require "settings"
# Combine the passed groups with the ones stored in settings
groups |= (Homebrew::Settings.read(:gemgroups)&.split(";") || [])
groups.sort!
ENV["BUNDLE_GEMFILE"] = File.join(ENV.fetch("HOMEBREW_LIBRARY"), "Homebrew", "Gemfile")
@bundle_installed ||= begin
ENV["BUNDLE_WITH"] = groups.join(" ")
if @bundle_installed_groups != groups
bundle = File.join(find_in_path("bundle"), "bundle")
bundle_check_output = `#{bundle} check 2>&1`
bundle_check_failed = !$CHILD_STATUS.success?
# for some reason sometimes the exit code lies so check the output too.
if bundle_check_failed || bundle_check_output.include?("Install missing gems")
unless system bundle, "install"
bundle_installed = if bundle_check_failed || bundle_check_output.include?("Install missing gems")
if system bundle, "install"
true
else
message = <<~EOS
failed to run `#{bundle} install`!
EOS
@ -153,10 +164,16 @@ module Homebrew
else
odie_if_defined message
end
false
end
else
true
end
if bundle_installed
Homebrew::Settings.write(:gemgroups, groups.join(";"))
@bundle_installed_groups = groups
end
end
setup_gem_environment!
@ -167,6 +184,7 @@ module Homebrew
ENV["GEM_PATH"] = old_gem_path
ENV["GEM_HOME"] = old_gem_home
ENV["BUNDLE_GEMFILE"] = old_bundle_gemfile
ENV["BUNDLE_WITH"] = old_bundle_with
end
end
end

View File

@ -22,6 +22,6 @@ module Homebrew
sig { void }
def install_bundler!; end
sig { params(only_warn_on_failure: T::Boolean, setup_path: T::Boolean).void }
def install_bundler_gems!(only_warn_on_failure: false, setup_path: false); end
sig { params(only_warn_on_failure: T::Boolean, setup_path: T::Boolean, groups: T::Array[String]).void }
def install_bundler_gems!(only_warn_on_failure: false, setup_path: false, groups: []); end
end

View File

@ -2,9 +2,7 @@
# typed: false
# frozen_string_literal: true
require_relative "gems"
Homebrew.setup_gem_environment!
require_relative "../standalone"
require_relative "../warnings"
Warnings.ignore :parser_syntax do

View File

@ -1,16 +0,0 @@
# typed: true
# frozen_string_literal: true
if ENV["HOMEBREW_SORBET_RUNTIME"]
Homebrew.install_bundler_gems!
require "sorbet-runtime"
else
# Explicitly prevent `sorbet-runtime` from being loaded.
def gem(name, *)
raise Gem::LoadError if name == "sorbet-runtime"
super
end
require "sorbet-runtime-stub"
end

View File

@ -79,10 +79,10 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-wait-0.0.9/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.7.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.0.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.16.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.16.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.10.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.3.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.4.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.3/lib"

View File

@ -351,6 +351,12 @@ RSpec/HooksBeforeExamples:
VersionAdded: '1.29'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
RSpec/IdenticalEqualityAssertion:
Description: Checks for equality assertions with identical expressions on both sides.
Enabled: pending
VersionAdded: '2.4'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IdenticalEqualityAssertion
RSpec/ImplicitBlockExpectation:
Description: Check that implicit block expectation syntax is not used.
Enabled: true
@ -753,6 +759,12 @@ RSpec/FactoryBot/FactoryClassName:
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName
RSpec/Rails/AvoidSetupHook:
Description: Checks that tests use RSpec `before` hook over Rails `setup` method.
Enabled: pending
VersionAdded: '2.4'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/AvoidSetupHook
RSpec/Rails/HttpStatus:
Description: Enforces use of symbolic or numeric value to describe HTTP status.
Enabled: true

View File

@ -203,7 +203,7 @@ module RuboCop
[name]
elsif namespace.const_type?
[*const_name(namespace), name]
elsif namespace.lvar_type? || namespace.cbase_type?
elsif %i[lvar cbase send].include?(namespace.type)
[nil, name]
end
end

Some files were not shown because too many files have changed in this diff Show More