Merge branch 'master' into integrate-uses

This commit is contained in:
William Ma 2020-08-01 11:55:40 -04:00
commit 72c672b814
98 changed files with 823 additions and 563 deletions

3
.github/codecov.yml vendored
View File

@ -6,3 +6,6 @@ coverage:
project:
default:
threshold: 0.05%
patch:
default:
informational: true

View File

@ -106,6 +106,9 @@ jobs:
# don't care about `brew cask style` here.
brew untap adoptopenjdk/openjdk
# don't care about `brew audit` here.
brew untap mongodb/brew
else
# Fix permissions for 'brew tests'
sudo chmod -R g-w,o-w /home/linuxbrew /home/runner /opt
@ -166,6 +169,9 @@ jobs:
if: matrix.os == 'macOS-latest'
run: brew cask style
- name: Run brew audit
run: brew audit --skip-style
- name: Run vale for docs linting
run: |
brew install vale

3
.gitignore vendored
View File

@ -86,11 +86,13 @@
**/vendor/bundle/ruby/*/gems/byebug-*/
**/vendor/bundle/ruby/*/gems/coderay-*/
**/vendor/bundle/ruby/*/gems/colorize-*/
**/vendor/bundle/ruby/*/gems/commander-*/
**/vendor/bundle/ruby/*/gems/connection_pool-*/
**/vendor/bundle/ruby/*/gems/codecov-*/
**/vendor/bundle/ruby/*/gems/diff-lcs-*/
**/vendor/bundle/ruby/*/gems/docile-*/
**/vendor/bundle/ruby/*/gems/domain_name-*/
**/vendor/bundle/ruby/*/gems/highline-*/
**/vendor/bundle/ruby/*/gems/http-cookie-*/
**/vendor/bundle/ruby/*/gems/hpricot-*/
**/vendor/bundle/ruby/*/gems/jaro_winkler-*/
@ -107,6 +109,7 @@
**/vendor/bundle/ruby/*/gems/ntlm-http-*/
**/vendor/bundle/ruby/*/gems/parallel-*/
**/vendor/bundle/ruby/*/gems/parallel_tests-*/
**/vendor/bundle/ruby/*/gems/parlour-*/
**/vendor/bundle/ruby/*/gems/parser-*/
**/vendor/bundle/ruby/*/gems/powerpack-*/
**/vendor/bundle/ruby/*/gems/psych-*/

View File

@ -181,7 +181,9 @@ Layout/LineLength:
Max: 118
# ignore manpage comments and long single-line strings
IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options ',
' appcast "', ' executable: "', '#{version.',
' appcast "', ' executable: "', ' font "', ' homepage "', ' name "',
' pkg "', ' pkgutil: "', '#{language}', '#{version.',
' "/Library/Application Support/', '"/Library/Caches/', '"/Library/PreferencePanes/',
' "~/Library/Application Support/', '"~/Library/Caches/', '"~/Application Support',
' was verified as official when first introduced to the cask']

View File

@ -41,6 +41,7 @@ begin
empty_argv = ARGV.empty?
help_flag_list = %w[-h --help --usage -?]
help_flag = !ENV["HOMEBREW_HELP"].nil?
help_cmd_index = nil
cmd = nil
ARGV.each_with_index do |arg, i|
@ -49,12 +50,17 @@ begin
if arg == "help" && !cmd
# Command-style help: `help <cmd>` is fine, but `<cmd> help` is not.
help_flag = true
help_cmd_index = i
elsif !cmd && !help_flag_list.include?(arg)
cmd = ARGV.delete_at(i)
cmd = Commands::HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
end
end
ARGV.delete_at(help_cmd_index) if help_cmd_index
Homebrew.args = Homebrew::CLI::Parser.new.parse(ARGV.dup.freeze, ignore_invalid_options: true)
path = PATH.new(ENV["PATH"])
homebrew_path = PATH.new(ENV["HOMEBREW_PATH"])
@ -117,7 +123,7 @@ begin
odie "Unknown command: #{cmd}" if !possible_tap || possible_tap.installed?
# Unset HOMEBREW_HELP to avoid confusing the tap
ENV.delete("HOMEBREW_HELP") if help_flag
with_env HOMEBREW_HELP: nil do
tap_commands = []
cgroup = Utils.popen_read("cat", "/proc/1/cgroup")
if %w[azpl_job actions_job docker garden kubepods].none? { |container| cgroup.include?(container) }
@ -126,7 +132,8 @@ begin
end
tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{possible_tap.name}]
safe_system(*tap_commands)
ENV["HOMEBREW_HELP"] = "1" if help_flag
end
exec HOMEBREW_BREW_FILE, cmd, *ARGV
end
rescue UsageError => e

View File

@ -336,6 +336,8 @@ fi
for arg in "$@"
do
[[ $arg = "--" ]] && break
if [[ $arg = "--help" || $arg = "-h" || $arg = "--usage" || $arg = "-?" ]]
then
export HOMEBREW_HELP="1"

View File

@ -47,7 +47,7 @@ module Cask
upgradable_casks.each do |(old_cask, new_cask)|
upgrade_cask(old_cask, new_cask)
rescue => e
caught_exceptions << e
caught_exceptions << e.exception("#{new_cask.full_name}: #{e}")
next
end

View File

@ -10,26 +10,21 @@ module Homebrew
# undefine tap to allow --tap argument
undef tap
def initialize(argv = ARGV.freeze, set_default_args: false)
def initialize
super()
@processed_options = []
@options_only = args_options_only(argv)
@flags_only = args_flags_only(argv)
@options_only = []
@flags_only = []
# Can set these because they will be overwritten by freeze_named_args!
# (whereas other values below will only be overwritten if passed).
self[:named_args] = argv.reject { |arg| arg.start_with?("-") }
self[:named_args] = []
self[:remaining] = []
end
# Set values needed before Parser#parse has been run.
return unless set_default_args
self[:build_from_source?] = argv.include?("--build-from-source") || argv.include?("-s")
self[:build_bottle?] = argv.include?("--build-bottle")
self[:force_bottle?] = argv.include?("--force-bottle")
self[:HEAD?] = argv.include?("--HEAD")
self[:devel?] = argv.include?("--devel")
self[:universal?] = argv.include?("--universal")
def freeze_remaining_args!(remaining_args)
self[:remaining] = remaining_args.freeze
end
def freeze_named_args!(named_args)
@ -43,8 +38,7 @@ module Homebrew
@kegs = nil
@kegs_casks = nil
self[:named_args] = named_args
self[:named_args].freeze
self[:named_args] = named_args.freeze
end
def freeze_processed_options!(processed_options)
@ -54,12 +48,8 @@ module Homebrew
@processed_options += processed_options
@processed_options.freeze
@options_only = args_options_only(cli_args)
@flags_only = args_flags_only(cli_args)
end
def passthrough
options_only - CLI::Parser.global_options.values.map(&:first).flatten
@options_only = cli_args.select { |a| a.start_with?("-") }.freeze
@flags_only = cli_args.select { |a| a.start_with?("--") }.freeze
end
def named
@ -219,16 +209,6 @@ module Homebrew
@cli_args.freeze
end
def args_options_only(args)
args.select { |arg| arg.start_with?("-") }
.freeze
end
def args_flags_only(args)
args.select { |arg| arg.start_with?("--") }
.freeze
end
def downcased_unique_named
# Only lowercase names, not paths, bottle filenames or URLs
named.map do |arg|

View File

@ -13,10 +13,6 @@ module Homebrew
class Parser
attr_reader :processed_options, :hide_from_man_page
def self.parse(argv = ARGV.freeze, allow_no_named_args: false, &block)
new(argv, &block).parse(allow_no_named_args: allow_no_named_args)
end
def self.from_cmd_path(cmd_path)
cmd_args_method_name = Commands.args_method_name(cmd_path)
@ -30,17 +26,17 @@ module Homebrew
end
def self.global_options
{
quiet: [["-q", "--quiet"], :quiet, "Suppress any warnings."],
verbose: [["-v", "--verbose"], :verbose, "Make some output more verbose."],
debug: [["-d", "--debug"], :debug, "Display any debugging information."],
}
[
["-q", "--quiet", "Suppress any warnings."],
["-v", "--verbose", "Make some output more verbose."],
["-d", "--debug", "Display any debugging information."],
]
end
def initialize(argv = ARGV.freeze, &block)
def initialize(&block)
@parser = OptionParser.new
@argv = argv
@args = Homebrew::CLI::Args.new(@argv)
@args = Homebrew::CLI::Args.new
@constraints = []
@conflicts = []
@ -50,25 +46,32 @@ module Homebrew
@min_named_args = nil
@min_named_type = nil
@hide_from_man_page = false
instance_eval(&block)
@formula_options = false
self.class.global_options.each do |short, long, desc|
switch short, long, description: desc
end
instance_eval(&block) if block_given?
post_initialize
end
def post_initialize
# Disable default handling of `--version` switch.
@parser.base.long.delete("version")
# Disable default handling of `--help` switch.
@parser.on_tail("-h", "--help", "Show this message.") do
puts generate_help_text
exit 0
# Handled in `brew.rb`.
end
end
def switch(*names, description: nil, env: nil, required_for: nil, depends_on: nil)
global_switch = names.first.is_a?(Symbol)
names, env, default_description = common_switch(*names) if global_switch
if description.nil? && global_switch
description = default_description
elsif description.nil?
description = option_to_description(*names)
end
return if global_switch
description = option_to_description(*names) if description.nil?
process_option(*names, description)
@parser.on(*names, *wrap_option_desc(description)) do
enable_switch(*names, from: :args)
@ -153,42 +156,51 @@ module Homebrew
@parser.to_s
end
def parse(argv = @argv, allow_no_named_args: false)
def parse_remaining(argv, ignore_invalid_options: false)
i = 0
remaining = []
argv, non_options = split_non_options(argv)
while i < argv.count
begin
begin
arg = argv[i]
remaining << arg unless @parser.parse([arg]).empty?
rescue OptionParser::MissingArgument
raise if i + 1 >= argv.count
args = argv[i..(i + 1)]
@parser.parse(args)
i += 1
end
rescue OptionParser::InvalidOption
if ignore_invalid_options
remaining << arg
else
$stderr.puts generate_help_text
raise
end
end
i += 1
end
[remaining, non_options]
end
def parse(argv = ARGV.freeze, ignore_invalid_options: false)
raise "Arguments were already parsed!" if @args_parsed
begin
named_args = @parser.parse(argv)
rescue OptionParser::InvalidOption => e
$stderr.puts generate_help_text
raise e
end
# If we accept formula options, parse once allowing invalid options
# so we can get the remaining list containing formula names.
if @formula_options
remaining, non_options = parse_remaining(argv, ignore_invalid_options: true)
check_constraint_violations
check_named_args(named_args, allow_no_named_args: allow_no_named_args)
@args.freeze_named_args!(named_args)
@args.freeze_processed_options!(@processed_options)
Homebrew.args = @args
argv = [*remaining, "--", *non_options]
@args_parsed = true
@args
end
def global_option?(name, desc)
Homebrew::CLI::Parser.global_options.key?(name.to_sym) &&
Homebrew::CLI::Parser.global_options[name.to_sym].last == desc
end
def generate_help_text
@parser.to_s
.sub(/^/, "#{Tty.bold}Usage: brew#{Tty.reset} ")
.gsub(/`(.*?)`/m, "#{Tty.bold}\\1#{Tty.reset}")
.gsub(%r{<([^\s]+?://[^\s]+?)>}) { |url| Formatter.url(url) }
.gsub(/<(.*?)>/m, "#{Tty.underline}\\1#{Tty.reset}")
.gsub(/\*(.*?)\*/m, "#{Tty.underline}\\1#{Tty.reset}")
end
def formula_options
formulae.each do |f|
formulae(argv).each do |f|
next if f.options.empty?
f.options.each do |o|
@ -201,8 +213,37 @@ module Homebrew
end
end
end
rescue FormulaUnavailableError
end
remaining, non_options = parse_remaining(argv, ignore_invalid_options: ignore_invalid_options)
named_args = if ignore_invalid_options
[]
else
remaining + non_options
end
check_constraint_violations unless ignore_invalid_options
check_named_args(named_args) unless ignore_invalid_options
@args.freeze_named_args!(named_args)
@args.freeze_remaining_args!(non_options.empty? ? remaining : [*remaining, "--", non_options])
@args.freeze_processed_options!(@processed_options)
@args_parsed = true
@args
end
def generate_help_text
@parser.to_s
.sub(/^/, "#{Tty.bold}Usage: brew#{Tty.reset} ")
.gsub(/`(.*?)`/m, "#{Tty.bold}\\1#{Tty.reset}")
.gsub(%r{<([^\s]+?://[^\s]+?)>}) { |url| Formatter.url(url) }
.gsub(/<(.*?)>/m, "#{Tty.underline}\\1#{Tty.reset}")
.gsub(/\*(.*?)\*/m, "#{Tty.underline}\\1#{Tty.reset}")
end
def formula_options
@formula_options = true
end
def max_named(count)
@ -256,11 +297,6 @@ module Homebrew
end
end
# These are common/global switches accessible throughout Homebrew
def common_switch(name)
Homebrew::CLI::Parser.global_options.fetch(name, name)
end
def option_passed?(name)
@args[name.to_sym] || @args["#{name}?".to_sym]
end
@ -328,8 +364,10 @@ module Homebrew
check_constraints
end
def check_named_args(args, allow_no_named_args: false)
def check_named_args(args)
min_exception = case @min_named_type
when :cask
Cask::CaskUnspecifiedError.new
when :formula
FormulaUnspecifiedError.new
when :keg
@ -337,8 +375,8 @@ module Homebrew
else
MinNamedArgumentsError.new(@min_named_args)
end
raise min_exception if !allow_no_named_args && !@min_named_args.nil? && args.size < @min_named_args
raise MaxNamedArgumentsError, @max_named_args if !@max_named_args.nil? && args.size > @max_named_args
raise min_exception if @min_named_args && args.size < @min_named_args
raise MaxNamedArgumentsError, @max_named_args if @max_named_args && args.size > @max_named_args
end
def process_option(*args)
@ -346,11 +384,21 @@ module Homebrew
@processed_options << [option.short.first, option.long.first, option.arg, option.desc.first]
end
def formulae
named_args = @argv.reject { |arg| arg.start_with?("-") }
spec = if @argv.include?("--HEAD")
def split_non_options(argv)
if sep = argv.index("--")
[argv.take(sep), argv.drop(sep + 1)]
else
[argv, []]
end
end
def formulae(argv)
argv, non_options = split_non_options(argv)
named_args = argv.reject { |arg| arg.start_with?("-") } + non_options
spec = if argv.include?("--HEAD")
:head
elsif @argv.include?("--devel")
elsif argv.include?("--devel")
:devel
else
:stable
@ -360,7 +408,11 @@ module Homebrew
named_args.map do |arg|
next if arg.match?(HOMEBREW_CASK_TAP_CASK_REGEX)
Formulary.factory(arg, spec, flags: @args.flags_only)
begin
Formulary.factory(arg, spec, flags: argv.select { |a| a.start_with?("--") })
rescue FormulaUnavailableError
nil
end
end.compact.uniq(&:name)
end
end

View File

@ -20,7 +20,7 @@ module Homebrew
end
def __cellar
__cellar_args.parse
args = __cellar_args.parse
if args.no_named?
puts HOMEBREW_CELLAR

View File

@ -20,7 +20,7 @@ module Homebrew
end
def __prefix
__prefix_args.parse
args = __prefix_args.parse
if args.no_named?
puts HOMEBREW_PREFIX

View File

@ -18,7 +18,7 @@ module Homebrew
end
def __repository
__repository_args.parse
args = __repository_args.parse
if args.no_named?
puts HOMEBREW_REPOSITORY

View File

@ -22,14 +22,12 @@ module Homebrew
`brew analytics regenerate-uuid`:
Regenerate the UUID used for Homebrew's analytics.
EOS
switch :verbose
switch :debug
max_named 1
end
end
def analytics
analytics_args.parse
args = analytics_args.parse
case args.named.first
when nil, "state"

View File

@ -27,13 +27,11 @@ module Homebrew
"If you want to delete those too: `rm -rf \"$(brew --cache)\"`"
switch "--prune-prefix",
description: "Only prune the symlinks and directories from the prefix and remove no other files."
switch :verbose
switch :debug
end
end
def cleanup
cleanup_args.parse
args = cleanup_args.parse
cleanup = Cleanup.new(*args.named, dry_run: args.dry_run?, scrub: args.s?, days: args.prune&.to_i)
if args.prune_prefix?

View File

@ -12,19 +12,18 @@ module Homebrew
Show lists of built-in and external commands.
EOS
switch :quiet,
switch "-q", "--quiet",
description: "List only the names of commands without category headers."
switch "--include-aliases",
depends_on: "--quiet",
description: "Include aliases of internal commands."
switch :verbose
switch :debug
max_named 0
end
end
def commands
commands_args.parse
args = commands_args.parse
if args.quiet?
puts Formatter.columns(Commands.commands(aliases: args.include_aliases?))

View File

@ -14,8 +14,7 @@ module Homebrew
Show Homebrew and system configuration info useful for debugging. If you file
a bug report, you will be required to provide this information.
EOS
switch :verbose
switch :debug
max_named 0
end
end

View File

@ -53,15 +53,14 @@ module Homebrew
description: "Switch into the mode used by the `--all` option, but only list dependencies "\
"for each provided <formula>, one formula per line. This is used for "\
"debugging the `--installed`/`--all` display mode."
switch :verbose
switch :debug
conflicts "--installed", "--all"
formula_options
end
end
def deps
deps_args.parse
args = deps_args.parse
Formulary.enable_factory_cache!
@ -84,13 +83,13 @@ module Homebrew
raise FormulaUnspecifiedError
end
puts_deps_tree dependents, recursive
puts_deps_tree dependents, recursive, args: args
return
elsif args.all?
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive, args: args
return
elsif !args.no_named? && args.for_each?
puts_deps sorted_dependents(args.formulae_and_casks), recursive
puts_deps sorted_dependents(args.formulae_and_casks), recursive, args: args
return
end
@ -103,9 +102,9 @@ module Homebrew
dependents = dependents(args.formulae_and_casks)
all_deps = deps_for_dependents(dependents, recursive, &(args.union? ? :| : :&))
all_deps = deps_for_dependents(dependents, recursive, args: args, &(args.union? ? :| : :&))
condense_requirements(all_deps)
all_deps.map!(&method(:dep_display_name))
all_deps.map! { |d| dep_display_name(d, args: args) }
all_deps.uniq!
all_deps.sort! unless args.n?
puts all_deps
@ -120,7 +119,7 @@ module Homebrew
deps.select! { |dep| dep.is_a?(Requirement) || dep.installed? } if args.installed?
end
def dep_display_name(dep)
def dep_display_name(dep, args:)
str = if dep.is_a? Requirement
if args.include_requirements?
":#{dep.display_s}"
@ -145,8 +144,8 @@ module Homebrew
str
end
def deps_for_dependent(d, recursive = false)
includes, ignores = argv_includes_ignores(ARGV)
def deps_for_dependent(d, recursive = false, args:)
includes, ignores = args_includes_ignores(args)
deps = d.runtime_dependencies if @use_runtime_dependencies
@ -161,31 +160,31 @@ module Homebrew
deps + reqs.to_a
end
def deps_for_dependents(dependents, recursive = false, &block)
dependents.map { |d| deps_for_dependent(d, recursive) }.reduce(&block)
def deps_for_dependents(dependents, recursive = false, args:, &block)
dependents.map { |d| deps_for_dependent(d, recursive, args: args) }.reduce(&block)
end
def puts_deps(dependents, recursive = false)
dependents.each do |d|
deps = deps_for_dependent(d, recursive)
def puts_deps(dependents, recursive = false, args:)
dependents.each do |dependent|
deps = deps_for_dependent(dependent, recursive, args: args)
condense_requirements(deps)
deps.sort_by!(&:name)
deps.map!(&method(:dep_display_name))
puts "#{d.full_name}: #{deps.join(" ")}"
deps.map! { |d| dep_display_name(d, args: args) }
puts "#{dependent.full_name}: #{deps.join(" ")}"
end
end
def puts_deps_tree(dependents, recursive = false)
def puts_deps_tree(dependents, recursive = false, args:)
dependents.each do |d|
puts d.full_name
@dep_stack = []
recursive_deps_tree(d, "", recursive)
recursive_deps_tree(d, "", recursive, args: args)
puts
end
end
def recursive_deps_tree(f, prefix, recursive)
includes, ignores = argv_includes_ignores(ARGV)
def recursive_deps_tree(f, prefix, recursive, args:)
includes, ignores = args_includes_ignores(args)
dependables = @use_runtime_dependencies ? f.runtime_dependencies : f.deps
deps = reject_ignores(dependables, ignores, includes)
reqs = reject_ignores(f.requirements, ignores, includes)
@ -202,7 +201,7 @@ module Homebrew
"├──"
end
display_s = "#{tree_lines} #{dep_display_name(dep)}"
display_s = "#{tree_lines} #{dep_display_name(dep, args: args)}"
is_circular = @dep_stack.include?(dep.name)
display_s = "#{display_s} (CIRCULAR DEPENDENCY)" if is_circular
puts "#{prefix}#{display_s}"
@ -215,7 +214,9 @@ module Homebrew
""
end
recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_addition, true) if dep.is_a? Dependency
if dep.is_a? Dependency
recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_addition, true, args: args)
end
end
@dep_stack.pop

View File

@ -28,14 +28,14 @@ module Homebrew
switch "-d", "--description",
description: "Search just descriptions for <text>. If <text> is flanked by slashes, "\
"it is interpreted as a regular expression."
switch :verbose
conflicts "--search", "--name", "--description"
min_named 1
end
end
def desc
desc_args.parse
args = desc_args.parse
search_type = if args.search?
:either

View File

@ -23,13 +23,11 @@ module Homebrew
"if provided as arguments."
switch "-D", "--audit-debug",
description: "Enable debugging and profiling of audit methods."
switch :verbose
switch :debug
end
end
def doctor
doctor_args.parse
args = doctor_args.parse
inject_dump_stats!(Diagnostic::Checks, /^check_*/) if args.audit_debug?

View File

@ -23,7 +23,7 @@ module Homebrew
description: "Fetch development version instead of stable version."
switch "-f", "--force",
description: "Remove a previously cached version and re-fetch."
switch :verbose,
switch "-v", "--verbose",
description: "Do a verbose VCS checkout, if the URL represents a VCS. This is useful for "\
"seeing if an existing VCS cache has been updated."
switch "--retry",
@ -38,7 +38,7 @@ module Homebrew
switch "--force-bottle",
description: "Download a bottle if it exists for the current or newest version of macOS, "\
"even if it would not be used during installation."
switch :debug
conflicts "--devel", "--HEAD"
conflicts "--build-from-source", "--build-bottle", "--force-bottle"
min_named :formula
@ -66,7 +66,7 @@ module Homebrew
fetched_bottle = false
if fetch_bottle?(f, args: args)
begin
fetch_formula(f.bottle)
fetch_formula(f.bottle, args: args)
rescue Interrupt
raise
rescue => e
@ -82,40 +82,40 @@ module Homebrew
next if fetched_bottle
fetch_formula(f)
fetch_formula(f, args: args)
f.resources.each do |r|
fetch_resource(r)
r.patches.each { |p| fetch_patch(p) if p.external? }
fetch_resource(r, args: args)
r.patches.each { |p| fetch_patch(p, args: args) if p.external? }
end
f.patchlist.each { |p| fetch_patch(p) if p.external? }
f.patchlist.each { |p| fetch_patch(p, args: args) if p.external? }
end
end
def fetch_resource(r)
def fetch_resource(r, args:)
puts "Resource: #{r.name}"
fetch_fetchable r
fetch_fetchable r, args: args
rescue ChecksumMismatchError => e
retry if retry_fetch? r
retry if retry_fetch?(r, args: args)
opoo "Resource #{r.name} reports different #{e.hash_type}: #{e.expected}"
end
def fetch_formula(f)
fetch_fetchable f
def fetch_formula(f, args:)
fetch_fetchable f, args: args
rescue ChecksumMismatchError => e
retry if retry_fetch? f
retry if retry_fetch?(f, args: args)
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end
def fetch_patch(p)
fetch_fetchable p
def fetch_patch(p, args:)
fetch_fetchable p, args: args
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Patch reports different #{e.hash_type}: #{e.expected}"
end
def retry_fetch?(f)
def retry_fetch?(f, args:)
@fetch_failed ||= Set.new
if args.retry? && @fetch_failed.add?(f)
ohai "Retrying download"
@ -127,7 +127,7 @@ module Homebrew
end
end
def fetch_fetchable(f)
def fetch_fetchable(f, args:)
f.clear_cache if args.force?
already_fetched = f.cached_download.exist?
@ -135,7 +135,7 @@ module Homebrew
begin
download = f.fetch(verify_download_integrity: false)
rescue DownloadError
retry if retry_fetch? f
retry if retry_fetch?(f, args: args)
raise
end

View File

@ -28,13 +28,12 @@ module Homebrew
switch "-p", "--private",
description: "The Gist will be marked private and will not appear in listings but will "\
"be accessible with its link."
switch :verbose
switch :debug
named :formula
end
end
def gistify_logs(f)
def gistify_logs(f, args:)
files = load_logs(f.logs)
build_time = f.logs.ctime
timestamp = build_time.strftime("%Y-%m-%d_%H-%M-%S")
@ -42,7 +41,7 @@ module Homebrew
s = StringIO.new
SystemConfig.dump_verbose_config s
# Dummy summary file, asciibetically first, to control display title of gist
files["# #{f.name} - #{timestamp}.txt"] = { content: brief_build_info(f) }
files["# #{f.name} - #{timestamp}.txt"] = { content: brief_build_info(f, with_hostname: args.with_hostname?) }
files["00.config.out"] = { content: s.string }
files["00.doctor.out"] = { content: Utils.popen_read("#{HOMEBREW_PREFIX}/bin/brew", "doctor", err: :out) }
unless f.core_formula?
@ -70,19 +69,19 @@ module Homebrew
else
"#{f.name} (#{f.full_name}) on #{OS_VERSION} - Homebrew build logs"
end
url = create_gist(files, descr)
url = create_gist(files, descr, private: args.private?)
url = create_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url) if args.new_issue?
puts url if url
end
def brief_build_info(f)
def brief_build_info(f, with_hostname:)
build_time_str = f.logs.ctime.strftime("%Y-%m-%d %H:%M:%S")
s = +<<~EOS
Homebrew build logs for #{f.full_name} on #{OS_VERSION}
EOS
if args.with_hostname?
if with_hostname
hostname = Socket.gethostname
s << "Host: #{hostname}\n"
end
@ -123,13 +122,9 @@ module Homebrew
logs
end
def create_private?
args.private?
end
def create_gist(files, description)
def create_gist(files, description, private:)
url = "https://api.github.com/gists"
data = { "public" => !create_private?, "files" => files, "description" => description }
data = { "public" => !private, "files" => files, "description" => description }
scopes = GitHub::CREATE_GIST_SCOPES
GitHub.open_api(url, data: data, scopes: scopes)["html_url"]
end
@ -142,10 +137,10 @@ module Homebrew
end
def gist_logs
gist_logs_args.parse
args = gist_logs_args.parse
Install.perform_preinstall_checks(all_fatal: true)
Install.perform_build_from_source_checks(all_fatal: true)
gistify_logs(args.resolved_formulae.first)
gistify_logs(args.resolved_formulae.first, args: args)
end
end

View File

@ -15,12 +15,11 @@ module Homebrew
Open <formula>'s homepage in a browser, or open Homebrew's own homepage
if no formula is provided.
EOS
switch :debug
end
end
def home
home_args.parse
args = home_args.parse
if args.no_named?
exec_browser HOMEBREW_WWW

View File

@ -52,15 +52,15 @@ module Homebrew
switch "--all",
depends_on: "--json",
description: "Print JSON of all available formulae."
switch :verbose,
switch "-v", "--verbose",
description: "Show more verbose analytics data for <formula>."
switch :debug
conflicts "--installed", "--all"
end
end
def info
info_args.parse
args = info_args.parse
if args.days.present?
raise UsageError, "--days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days)
@ -83,17 +83,17 @@ module Homebrew
raise FormulaUnspecifiedError if args.no_named?
end
print_json
print_json(args: args)
elsif args.github?
raise FormulaUnspecifiedError if args.no_named?
exec_browser(*args.formulae.map { |f| github_info(f) })
else
print_info
print_info(args: args)
end
end
def print_info
def print_info(args:)
if args.no_named?
if args.analytics?
Utils::Analytics.output(args: args)
@ -126,7 +126,7 @@ module Homebrew
end
end
def print_json
def print_json(args:)
ff = if args.all?
Formula.sort
elsif args.installed?

View File

@ -24,7 +24,7 @@ module Homebrew
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
installed formulae or, every 30 days, for all formulae.
EOS
switch :debug,
switch "-d", "--debug",
description: "If brewing fails, open an interactive debugging session with access to IRB "\
"or a shell inside the temporary build directory."
flag "--env=",
@ -74,7 +74,7 @@ module Homebrew
switch "-f", "--force",
description: "Install without checking for previously installed keg-only or "\
"non-migrated versions."
switch :verbose,
switch "-v", "--verbose",
description: "Print the verification and postinstall steps."
switch "--display-times",
env: :display_install_times,

View File

@ -14,7 +14,7 @@ module Homebrew
List installed formulae that are not dependencies of another installed formula.
EOS
switch :debug
max_named 0
end
end

View File

@ -23,14 +23,13 @@ module Homebrew
"`brew link --overwrite` without actually linking or deleting any files."
switch "-f", "--force",
description: "Allow keg-only formulae to be linked."
switch :verbose
switch :debug
min_named :keg
end
end
def link
link_args.parse
args = link_args.parse
mode = OpenStruct.new

View File

@ -45,16 +45,15 @@ module Homebrew
description: "Reverse the order of the sort to list the oldest entries first."
switch "-t",
description: "Sort by time modified, listing most recently modified first."
switch :verbose
switch :debug
["--unbrewed", "--multiple", "--pinned", "-l", "-r", "-t"].each { |flag| conflicts "--cask", flag }
end
end
def list
list_args.parse
args = list_args.parse
return list_casks if args.cask?
return list_casks(args: args) if args.cask?
return list_unbrewed if args.unbrewed?
@ -67,7 +66,7 @@ module Homebrew
end
if args.pinned? || args.versions?
filtered_list
filtered_list args: args
elsif args.no_named?
if args.full_name?
full_names = Formula.installed.map(&:full_name).sort(&tap_and_name_comparison)
@ -76,7 +75,14 @@ module Homebrew
puts Formatter.columns(full_names)
else
ENV["CLICOLOR"] = nil
safe_system "ls", *args.passthrough << HOMEBREW_CELLAR
ls_args = []
ls_args << "-1" if args.public_send(:'1?')
ls_args << "-l" if args.l?
ls_args << "-r" if args.r?
ls_args << "-t" if args.t?
safe_system "ls", *ls_args, HOMEBREW_CELLAR
end
elsif args.verbose? || !$stdout.tty?
system_command! "find", args: args.kegs.map(&:to_s) + %w[-not -type d -print], print_stdout: true
@ -128,7 +134,7 @@ module Homebrew
safe_system "find", *arguments
end
def filtered_list
def filtered_list(args:)
names = if args.no_named?
Formula.racks
else
@ -157,7 +163,7 @@ module Homebrew
end
end
def list_casks
def list_casks(args:)
cask_list = Cask::Cmd::List.new args.named
cask_list.one = ARGV.include? "-1"
cask_list.versions = args.versions?

View File

@ -20,14 +20,17 @@ module Homebrew
description: "Also print diffstat from commit."
switch "--oneline",
description: "Print only one line per commit."
flag "-1", "--max-count",
description: "Print only one or a specified number of commits."
switch "-1",
description: "Print only one commit."
flag "-n", "--max-count=",
description: "Print only a specified number of commits."
max_named 1
conflicts "-1", "--max-count"
end
end
def log
log_args.parse
args = log_args.parse
# As this command is simplifying user-run commands then let's just use a
# user path, too.
@ -38,11 +41,11 @@ module Homebrew
else
path = Formulary.path(args.named.first)
tap = Tap.from_path(path)
git_log path.dirname, path, tap
git_log path.dirname, path, tap, args: args
end
end
def git_log(cd_dir, path = nil, tap = nil)
def git_log(cd_dir, path = nil, tap = nil, args:)
cd cd_dir
repo = Utils.popen_read("git rev-parse --show-toplevel").chomp
if tap
@ -62,8 +65,14 @@ module Homebrew
git -C "#{git_cd}" fetch --unshallow
EOS
end
system_args = args.options_only
system_args += ["--follow", "--", path] if path.present?
system "git", "log", *system_args
git_args = []
git_args << "--patch" if args.patch?
git_args << "--stat" if args.stat?
git_args << "--oneline" if args.oneline?
git_args << "-1" if args.public_send(:'1?')
git_args << "--max-count" << args.max_count if args.max_count
git_args += ["--follow", "--", path] if path.present?
system "git", "log", *git_args
end
end

View File

@ -17,8 +17,7 @@ module Homebrew
switch "-f", "--force",
description: "Treat installed <formula> and provided <formula> as if they are from "\
"the same taps and migrate them anyway."
switch :verbose
switch :debug
min_named :formula
end
end

View File

@ -20,13 +20,11 @@ module Homebrew
comma_array "--hide",
description: "Act as if none of the specified <hidden> are installed. <hidden> should be "\
"a comma-separated list of formulae."
switch :verbose
switch :debug
end
end
def missing
missing_args.parse
args = missing_args.parse
return unless HOMEBREW_CELLAR.exist?

View File

@ -23,18 +23,18 @@ module Homebrew
description: "Show options for all available formulae."
flag "--command=",
description: "Show options for the specified <command>."
switch :debug
conflicts "--installed", "--all", "--command"
end
end
def options
options_args.parse
args = options_args.parse
if args.all?
puts_options Formula.to_a.sort
puts_options Formula.to_a.sort, args: args
elsif args.installed?
puts_options Formula.installed.sort
puts_options Formula.installed.sort, args: args
elsif !args.command.nil?
path = Commands.path(args.command)
odie "Unknown command: #{args.command}" unless path
@ -54,7 +54,7 @@ module Homebrew
elsif args.no_named?
raise FormulaUnspecifiedError
else
puts_options args.formulae
puts_options args.formulae, args: args
end
end
@ -72,7 +72,7 @@ module Homebrew
options
end
def puts_options(formulae)
def puts_options(formulae, args:)
formulae.each do |f|
next if f.options.empty?

View File

@ -17,9 +17,9 @@ module Homebrew
List installed formulae that have an updated version available. By default, version
information is displayed in interactive shells, and suppressed otherwise.
EOS
switch :quiet,
switch "-q", "--quiet",
description: "List only the names of outdated kegs (takes precedence over `--verbose`)."
switch :verbose,
switch "-v", "--verbose",
description: "Include detailed version information."
flag "--json",
description: "Print output in JSON format. There are two versions: v1 and v2. " \
@ -35,16 +35,16 @@ module Homebrew
description: "Treat all arguments as formulae."
switch "--cask",
description: "Treat all arguments as casks."
switch :debug
conflicts "--quiet", "--verbose", "--json"
conflicts "--formula", "--cask"
end
end
def outdated
outdated_args.parse
args = outdated_args.parse
case json_version
case json_version(args.json)
when :v1, :default
# TODO: enable for next major/minor release
# odeprecated "brew outdated --json#{json_version == :v1 ? "=v1" : ""}", "brew outdated --json=v2"
@ -55,7 +55,7 @@ module Homebrew
outdated_casks
end
puts JSON.generate(json_info(outdated))
puts JSON.generate(json_info(outdated, args: args))
when :v2
formulae, casks = if args.formula?
@ -67,8 +67,8 @@ module Homebrew
end
json = {
"formulae" => json_info(formulae),
"casks" => json_info(casks),
"formulae" => json_info(formulae, args: args),
"casks" => json_info(casks, args: args),
}
puts JSON.generate(json)
@ -83,13 +83,13 @@ module Homebrew
outdated_formulae_casks.flatten
end
print_outdated(outdated)
print_outdated(outdated, args: args)
end
Homebrew.failed = args.named.present? && outdated.present?
end
def print_outdated(formulae_or_casks)
def print_outdated(formulae_or_casks, args:)
formulae_or_casks.each do |formula_or_cask|
if formula_or_cask.is_a?(Formula)
f = formula_or_cask
@ -127,7 +127,7 @@ module Homebrew
end
end
def json_info(formulae_or_casks)
def json_info(formulae_or_casks, args:)
formulae_or_casks.map do |formula_or_cask|
if formula_or_cask.is_a?(Formula)
f = formula_or_cask
@ -156,7 +156,7 @@ module Homebrew
($stdout.tty? || args.verbose?) && !args.quiet?
end
def json_version
def json_version(version)
version_hash = {
nil => nil,
true => :default,
@ -164,9 +164,9 @@ module Homebrew
"v2" => :v2,
}
raise UsageError, "invalid JSON version: #{args.json}" unless version_hash.include? args.json
raise UsageError, "invalid JSON version: #{version}" unless version_hash.include?(version)
version_hash[args.json]
version_hash[version]
end
def outdated_formulae

View File

@ -14,13 +14,13 @@ module Homebrew
Pin the specified <formula>, preventing them from being upgraded when
issuing the `brew upgrade` <formula> command. See also `unpin`.
EOS
switch :debug
min_named :formula
end
end
def pin
pin_args.parse
args = pin_args.parse
args.resolved_formulae.each do |f|
if f.pinned?

View File

@ -14,8 +14,7 @@ module Homebrew
Rerun the post-install steps for <formula>.
EOS
switch :verbose
switch :debug
min_named :keg
end
end

View File

@ -20,13 +20,11 @@ module Homebrew
description: "Verify any alias symlinks in each tap."
switch "--syntax",
description: "Syntax-check all of Homebrew's Ruby files (if no `<tap>` is passed)."
switch :verbose
switch :debug
end
end
def readall
readall_args.parse
args = readall_args.parse
if args.syntax? && args.no_named?
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"

View File

@ -26,7 +26,7 @@ module Homebrew
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
reinstalled formulae or, every 30 days, for all formulae.
EOS
switch :debug,
switch "-d", "--debug",
description: "If brewing fails, open an interactive debugging session with access to IRB "\
"or a shell inside the temporary build directory."
switch "-s", "--build-from-source",
@ -43,7 +43,7 @@ module Homebrew
switch "-f", "--force",
description: "Install without checking for previously installed keg-only or "\
"non-migrated versions."
switch :verbose,
switch "-v", "--verbose",
description: "Print the verification and postinstall steps."
switch "--display-times",
env: :display_install_times,

View File

@ -51,14 +51,13 @@ module Homebrew
switch s,
description: "Search for <text> in the given package manager's list."
end
switch :verbose
switch :debug
conflicts(*package_manager_switches)
end
end
def search
search_args.parse
args = search_args.parse
if package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] }
_, url = package_manager

View File

@ -14,14 +14,13 @@ module Homebrew
Symlink all of the specified <version> of <formula>'s installation into Homebrew's prefix.
EOS
switch :verbose
switch :debug
named 2
end
end
def switch
switch_args.parse
args = switch_args.parse
name = args.named.first
rack = Formulary.to_rack(name)

View File

@ -20,12 +20,11 @@ module Homebrew
description: "Print a JSON representation of <tap>. Currently the default and only accepted "\
"value for <version> is `v1`. See the docs for examples of using the JSON "\
"output: <https://docs.brew.sh/Querying-Brew>"
switch :debug
end
end
def tap_info
tap_info_args.parse
args = tap_info_args.parse
taps = if args.installed?
Tap

View File

@ -36,14 +36,13 @@ module Homebrew
description: "Migrate tapped formulae from symlink-based to directory-based structure."
switch "--list-pinned",
description: "List all pinned taps."
switch :quiet
switch :debug
max_named 2
end
end
def tap
tap_args.parse
args = tap_args.parse
if args.repair?
Tap.each(&:link_completions_and_manpages)
@ -63,7 +62,7 @@ module Homebrew
tap = Tap.fetch(args.named.first)
begin
tap.install clone_target: args.named.second,
force_auto_update: force_auto_update?,
force_auto_update: force_auto_update?(args: args),
quiet: args.quiet?,
full_clone: full_clone
rescue TapRemoteMismatchError => e
@ -74,7 +73,7 @@ module Homebrew
end
end
def force_auto_update?
def force_auto_update?(args:)
# if no relevant flag is present, return nil, meaning "no change"
true if args.force_auto_update?
end

View File

@ -24,7 +24,7 @@ module Homebrew
switch "--ignore-dependencies",
description: "Don't fail uninstall, even if <formula> is a dependency of any installed "\
"formulae."
switch :debug
min_named :formula
end
end

View File

@ -18,14 +18,13 @@ module Homebrew
switch "-n", "--dry-run",
description: "List files which would be unlinked without actually unlinking or "\
"deleting any files."
switch :verbose
switch :debug
min_named :keg
end
end
def unlink
unlink_args.parse
args = unlink_args.parse
mode = OpenStruct.new
mode.dry_run = true if args.dry_run?

View File

@ -14,14 +14,13 @@ module Homebrew
Unpin <formula>, allowing them to be upgraded by `brew upgrade` <formula>.
See also `pin`.
EOS
switch :verbose
switch :debug
min_named :formula
end
end
def unpin
unpin_args.parse
args = unpin_args.parse
args.resolved_formulae.each do |f|
if f.pinned?

View File

@ -12,13 +12,13 @@ module Homebrew
Remove a tapped formula repository.
EOS
switch :debug
min_named 1
end
end
def untap
untap_args.parse
args = untap_args.parse
args.named.each do |tapname|
tap = Tap.fetch(tapname)

View File

@ -30,9 +30,7 @@ module Homebrew
switch "-f", "--force",
description: "Treat installed and updated formulae as if they are from "\
"the same taps and migrate them anyway."
switch :quiet
switch :verbose
switch :debug
hide_from_man_page!
end
end

View File

@ -23,7 +23,7 @@ module Homebrew
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
upgraded formulae or, every 30 days, for all formulae.
EOS
switch :debug,
switch "-d", "--debug",
description: "If brewing fails, open an interactive debugging session with access to IRB "\
"or a shell inside the temporary build directory."
switch "-s", "--build-from-source",
@ -46,7 +46,7 @@ module Homebrew
switch "-f", "--force",
description: "Install without checking for previously installed keg-only or "\
"non-migrated versions."
switch :verbose,
switch "-v", "--verbose",
description: "Print the verification and postinstall steps."
switch "--display-times",
env: :display_install_times,
@ -71,7 +71,7 @@ module Homebrew
named_casks_specified = !casks.empty? && formulae.empty?
upgrade_outdated_formulae(formulae, args: args) unless named_casks_specified
upgrade_outdated_casks(casks) unless named_formulae_specified
upgrade_outdated_casks(casks, args: args) unless named_formulae_specified
end
def upgrade_outdated_formulae(formulae, args:)
@ -132,7 +132,7 @@ module Homebrew
Homebrew.messages.display_messages(display_times: args.display_times?)
end
def upgrade_outdated_casks(casks)
def upgrade_outdated_casks(casks, args:)
cask_upgrade = Cask::Cmd::Upgrade.new(casks)
cask_upgrade.force = args.force?
cask_upgrade.dry_run = args.dry_run?

View File

@ -40,14 +40,14 @@ module Homebrew
description: "Show usage of <formula> by development builds."
switch "--HEAD",
description: "Show usage of <formula> by HEAD builds."
switch :debug
conflicts "--devel", "--HEAD"
min_named :formula
end
end
def uses
uses_args.parse
args = uses_args.parse
odeprecated "brew uses --devel" if args.devel?
odeprecated "brew uses --HEAD" if args.HEAD?
@ -70,11 +70,14 @@ module Homebrew
!args.include_optional? &&
!args.skip_recommended?
recursive = args.recursive?
includes, ignores = args_includes_ignores(args)
uses = if use_runtime_dependents && !used_formulae_missing
used_formulae.map(&:runtime_installed_formula_dependents)
.reduce(&:&)
.select(&:any_version_installed?) +
select_used_dependents(dependents(Cask::Caskroom.casks), used_formulae)
select_used_dependents(dependents(Cask::Caskroom.casks), used_formulae, recursive, includes, ignores)
else
deps = if args.installed?
dependents(Formula.installed + Cask::Caskroom.casks)
@ -82,7 +85,7 @@ module Homebrew
dependents(Formula.to_a + Cask::Cask.to_a)
end
select_used_dependents(deps, used_formulae)
select_used_dependents(deps, used_formulae, recursive, includes, ignores)
end
return if uses.empty?
@ -91,10 +94,7 @@ module Homebrew
odie "Missing formulae should not have dependents!" if used_formulae_missing
end
def select_used_dependents(dependents, used_formulae)
recursive = args.recursive?
includes, ignores = argv_includes_ignores(ARGV)
def select_used_dependents(dependents, used_formulae, recursive, includes, ignores)
dependents.select do |d|
deps = if recursive
recursive_includes(Dependency, d, includes, ignores)

View File

@ -3,23 +3,23 @@
require "cask_dependent"
module DependenciesHelpers
def argv_includes_ignores(argv)
def args_includes_ignores(args)
includes = []
ignores = []
if argv.include? "--include-build"
if args.include_build?
includes << "build?"
else
ignores << "build?"
end
if argv.include? "--include-test"
if args.include_test?
includes << "test?"
else
ignores << "test?"
end
if argv.include? "--include-optional"
if args.include_optional?
includes << "optional?"
else
ignores << "optional?"
@ -46,7 +46,7 @@ module DependenciesHelpers
klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
elsif dep.build? || dep.test?
keep = false
keep ||= dep.test? && includes.include?("test?") && dependent == formula
keep ||= dep.test? && includes.include?("test?") && dependent == root_dependent
keep ||= dep.build? && includes.include?("build?")
klass.prune unless keep
end

View File

@ -61,8 +61,7 @@ module Homebrew
comma_array "--except-cops",
description: "Specify a comma-separated <cops> list to skip checking for violations of the listed "\
"RuboCop cops."
switch :verbose
switch :debug
conflicts "--only", "--except"
conflicts "--only-cops", "--except-cops", "--strict"
conflicts "--only-cops", "--except-cops", "--only"
@ -269,6 +268,12 @@ module Homebrew
valid_alias_names.map! { |a| "#{formula.tap}/#{a}" }
end
# Fix naming based on what people expect.
if alias_name_major_minor == "adoptopenjdk@1.8"
valid_alias_names << "adoptopenjdk@8"
valid_alias_names.delete "adoptopenjdk@1"
end
valid_versioned_aliases = versioned_aliases & valid_alias_names
invalid_versioned_aliases = versioned_aliases - valid_alias_names
@ -284,7 +289,7 @@ module Homebrew
end
end
unless invalid_versioned_aliases.empty?
if invalid_versioned_aliases.present?
problem <<~EOS
Formula has invalid versioned aliases:
#{invalid_versioned_aliases.join("\n ")}
@ -385,7 +390,7 @@ module Homebrew
end
if self.class.aliases.include?(dep.name) &&
(dep_f.core_formula? || !dep_f.versioned_formula?)
dep_f.core_formula? && !dep_f.versioned_formula?
problem "Dependency '#{dep.name}' from homebrew/core is an alias; " \
"use the canonical name '#{dep.to_formula.full_name}'."
end
@ -467,6 +472,7 @@ module Homebrew
end
end
# openssl@1.1 only needed for Linux
VERSIONED_KEG_ONLY_ALLOWLIST = %w[
autoconf@2.13
bash-completion@2
@ -474,6 +480,7 @@ module Homebrew
libsigc++@2
lua@5.1
numpy@1.16
openssl@1.1
python@3.8
].freeze
@ -489,7 +496,9 @@ module Homebrew
end
end
return if VERSIONED_KEG_ONLY_ALLOWLIST.include?(formula.name) || formula.name.start_with?("gcc@")
return if VERSIONED_KEG_ONLY_ALLOWLIST.include?(formula.name)
return if formula.name.start_with?("adoptopenjdk@")
return if formula.name.start_with?("gcc@")
problem "Versioned formulae in homebrew/core should use `keg_only :versioned_formula`"
end

View File

@ -76,21 +76,20 @@ module Homebrew
"to the formula file."
flag "--root-url=",
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
switch :verbose
switch :debug
conflicts "--no-rebuild", "--keep-old"
min_named 1
end
end
def bottle
bottle_args.parse
args = bottle_args.parse
return merge if args.merge?
return merge(args: args) if args.merge?
ensure_relocation_formulae_installed! unless args.skip_relocation?
args.resolved_formulae.each do |f|
bottle_formula f
bottle_formula f, args: args
end
end
@ -103,7 +102,7 @@ module Homebrew
end
end
def keg_contain?(string, keg, ignores, formula_and_runtime_deps_names = nil)
def keg_contain?(string, keg, ignores, formula_and_runtime_deps_names = nil, args:)
@put_string_exists_header, @put_filenames = nil
print_filename = lambda do |str, filename|
@ -211,7 +210,7 @@ module Homebrew
system "/usr/bin/sudo", "--non-interactive", "/usr/sbin/purge"
end
def bottle_formula(f)
def bottle_formula(f, args:)
return ofail "Formula not installed or up-to-date: #{f.full_name}" unless f.latest_version_installed?
unless tap = f.tap
@ -328,14 +327,14 @@ module Homebrew
if args.skip_relocation?
skip_relocation = true
else
relocatable = false if keg_contain?(prefix_check, keg, ignores, formula_and_runtime_deps_names)
relocatable = false if keg_contain?(repository, keg, ignores)
relocatable = false if keg_contain?(cellar, keg, ignores, formula_and_runtime_deps_names)
relocatable = false if keg_contain?(prefix_check, keg, ignores, formula_and_runtime_deps_names, args: args)
relocatable = false if keg_contain?(repository, keg, ignores, args: args)
relocatable = false if keg_contain?(cellar, keg, ignores, formula_and_runtime_deps_names, args: args)
if prefix != prefix_check
relocatable = false if keg_contain_absolute_symlink_starting_with?(prefix, keg)
relocatable = false if keg_contain?("#{prefix}/etc", keg, ignores)
relocatable = false if keg_contain?("#{prefix}/var", keg, ignores)
relocatable = false if keg_contain?("#{prefix}/share/vim", keg, ignores)
relocatable = false if keg_contain?("#{prefix}/etc", keg, ignores, args: args)
relocatable = false if keg_contain?("#{prefix}/var", keg, ignores, args: args)
relocatable = false if keg_contain?("#{prefix}/share/vim", keg, ignores, args: args)
end
skip_relocation = relocatable && !keg.require_relocation?
end
@ -434,7 +433,7 @@ module Homebrew
end
end
def merge
def merge(args:)
bottles_hash = args.named.reduce({}) do |hash, json_file|
hash.deep_merge(JSON.parse(IO.read(json_file))) do |key, first, second|
if key == "cellar"

View File

@ -65,16 +65,14 @@ module Homebrew
description: "Specify the new git commit <revision> corresponding to the specified <tag>."
switch "-f", "--force",
description: "Ignore duplicate open PRs. Remove all mirrors if --mirror= was not specified."
switch :quiet
switch :verbose
switch :debug
conflicts "--no-audit", "--strict"
conflicts "--url", "--tag"
max_named 1
end
end
def use_correct_linux_tap(formula)
def use_correct_linux_tap(formula, args:)
if OS.linux? && formula.tap.core_tap?
tap_full_name = formula.tap.full_name.gsub("linuxbrew", "homebrew")
homebrew_core_url = "https://github.com/#{tap_full_name}"
@ -111,7 +109,7 @@ module Homebrew
end
def bump_formula_pr
bump_formula_pr_args.parse
args = bump_formula_pr_args.parse
# As this command is simplifying user-run commands then let's just use a
# user path, too.
@ -126,11 +124,11 @@ module Homebrew
formula ||= determine_formula_from_url(new_url) if new_url
raise FormulaUnspecifiedError unless formula
tap_full_name, origin_branch, previous_branch = use_correct_linux_tap(formula)
check_open_pull_requests(formula, tap_full_name)
tap_full_name, origin_branch, previous_branch = use_correct_linux_tap(formula, args: args)
check_open_pull_requests(formula, tap_full_name, args: args)
new_version = args.version
check_all_pull_requests(formula, tap_full_name, version: new_version) if new_version
check_all_pull_requests(formula, tap_full_name, version: new_version, args: args) if new_version
requested_spec = :stable
formula_spec = formula.stable
@ -161,10 +159,10 @@ module Homebrew
old_version = old_formula_version.to_s
forced_version = new_version.present?
new_url_hash = if new_url && new_hash
check_all_pull_requests(formula, tap_full_name, url: new_url) unless new_version
check_all_pull_requests(formula, tap_full_name, url: new_url, args: args) unless new_version
true
elsif new_tag && new_revision
check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag) unless new_version
check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version
false
elsif !hash_type
odie "#{formula}: no --tag= or --version= argument specified!" if !new_tag && !new_version
@ -175,7 +173,7 @@ module Homebrew
and old tag are both #{new_tag}.
EOS
end
check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag) unless new_version
check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version
resource_path, forced_version = fetch_resource(formula, new_version, old_url, tag: new_tag)
new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD")
new_revision = new_revision.strip
@ -183,6 +181,7 @@ module Homebrew
elsif !new_url && !new_version
odie "#{formula}: no --url= or --version= argument specified!"
else
new_url ||= PyPI.update_pypi_url(old_url, new_version)
new_url ||= old_url.gsub(old_version, new_version)
if new_url == old_url
odie <<~EOS
@ -191,7 +190,7 @@ module Homebrew
#{new_url}
EOS
end
check_all_pull_requests(formula, tap_full_name, url: new_url) unless new_version
check_all_pull_requests(formula, tap_full_name, url: new_url, args: args) unless new_version
resource_path, forced_version = fetch_resource(formula, new_version, new_url)
tar_file_extensions = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ]
if tar_file_extensions.any? { |extension| new_url.include? extension }
@ -295,7 +294,7 @@ module Homebrew
"",
]
end
new_contents = inreplace_pairs(formula.path, replacement_pairs.uniq.compact)
new_contents = inreplace_pairs(formula.path, replacement_pairs.uniq.compact, args: args)
new_formula_version = formula_version(formula, requested_spec, new_contents)
@ -335,10 +334,10 @@ module Homebrew
PyPI.update_python_resources! formula, new_formula_version, silent: true, ignore_non_pypi_packages: true
end
run_audit(formula, alias_rename, old_contents)
run_audit(formula, alias_rename, old_contents, args: args)
formula.path.parent.cd do
branch = "#{formula.name}-#{new_formula_version}"
branch = "bump-#{formula.name}-#{new_formula_version}"
git_dir = Utils.popen_read("git rev-parse --git-dir").chomp
shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow")
changed_files = [formula.path]
@ -450,7 +449,7 @@ module Homebrew
[remote_url, username]
end
def inreplace_pairs(path, replacement_pairs)
def inreplace_pairs(path, replacement_pairs, args:)
if args.dry_run?
str = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read }
contents = StringInreplaceExtension.new(str)
@ -497,13 +496,13 @@ module Homebrew
[]
end
def check_open_pull_requests(formula, tap_full_name)
def check_open_pull_requests(formula, tap_full_name, args:)
# check for open requests
pull_requests = fetch_pull_requests(formula.name, tap_full_name, state: "open")
check_for_duplicate_pull_requests(pull_requests)
check_for_duplicate_pull_requests(pull_requests, args: args)
end
def check_all_pull_requests(formula, tap_full_name, version: nil, url: nil, tag: nil)
def check_all_pull_requests(formula, tap_full_name, version: nil, url: nil, tag: nil, args:)
unless version
specs = {}
specs[:tag] = tag if tag
@ -511,10 +510,10 @@ module Homebrew
end
# if we haven't already found open requests, try for an exact match across all requests
pull_requests = fetch_pull_requests("#{formula.name} #{version}", tap_full_name) if pull_requests.blank?
check_for_duplicate_pull_requests(pull_requests)
check_for_duplicate_pull_requests(pull_requests, args: args)
end
def check_for_duplicate_pull_requests(pull_requests)
def check_for_duplicate_pull_requests(pull_requests, args:)
return if pull_requests.blank?
duplicates_message = <<~EOS
@ -546,7 +545,7 @@ module Homebrew
[versioned_alias, "#{name}@#{new_alias_version}"]
end
def run_audit(formula, alias_rename, old_contents)
def run_audit(formula, alias_rename, old_contents, args:)
if args.dry_run?
if args.no_audit?
ohai "Skipping `brew audit`"

View File

@ -18,9 +18,7 @@ module Homebrew
description: "Print what would be done rather than doing it."
flag "--message=",
description: "Append <message> to the default commit message."
switch :quiet
switch :verbose
switch :debug
named :formula
end
end
@ -42,9 +40,14 @@ module Homebrew
end
old = if formula.license
license_string = if formula.license.length > 1
formula.license
else
"\"#{formula.license.first}\""
end
# insert replacement revision after license
<<~EOS
license "#{formula.license}"
license #{license_string}
EOS
elsif formula.path.read.include?("stable do\n")
# insert replacement revision after homepage
@ -59,7 +62,7 @@ module Homebrew
else
# insert replacement revision after :revision
<<~EOS
:revision => "#{formula_spec.specs[:revision]}"
revision: "#{formula_spec.specs[:revision]}"
EOS
end
replacement = old + " revision 1\n"

View File

@ -17,7 +17,7 @@ module Homebrew
end
def cat
cat_args.parse
args = cat_args.parse
cd HOMEBREW_REPOSITORY
pager = if Homebrew::EnvConfig.bat?
@ -26,6 +26,6 @@ module Homebrew
else
"cat"
end
safe_system pager, args.formulae_paths.first, *args.passthrough
safe_system pager, args.formulae_paths.first
end
end

View File

@ -13,14 +13,13 @@ module Homebrew
Display the path to the file being used when invoking `brew` <cmd>.
EOS
switch :verbose
switch :debug
min_named 1
end
end
def command
command_args.parse
args = command_args.parse
args.named.each do |cmd|
path = Commands.path(cmd)

View File

@ -56,8 +56,7 @@ module Homebrew
description: "Generate the new formula within the given tap, specified as <user>`/`<repo>."
switch "-f", "--force",
description: "Ignore errors for disallowed formula names and named that shadow aliases."
switch :verbose
switch :debug
conflicts "--autotools", "--cmake", "--crystal", "--go", "--meson", "--node", "--perl", "--python", "--rust"
named 1
end

View File

@ -19,14 +19,13 @@ module Homebrew
description: "Explicitly set the <name> of the package being installed."
flag "--version=",
description: "Explicitly set the <version> of the package being installed."
switch :verbose
switch :debug
max_named 0
end
end
def diy
diy_args.parse
args = diy_args.parse
path = Pathname.getwd

View File

@ -14,13 +14,11 @@ module Homebrew
Open <formula> in the editor set by `EDITOR` or `HOMEBREW_EDITOR`, or open the
Homebrew repository for editing if no formula is provided.
EOS
switch :verbose
switch :debug
end
end
def edit
edit_args.parse
args = edit_args.parse
unless (HOMEBREW_REPOSITORY/".git").directory?
raise <<~EOS

View File

@ -91,13 +91,13 @@ module Homebrew
description: "Extract the specified <version> of <formula> instead of the most recent."
switch "-f", "--force",
description: "Overwrite the destination formula if it already exists."
switch :debug
named 2
end
end
def extract
extract_args.parse
args = extract_args.parse
if args.named.first !~ HOMEBREW_TAP_FORMULA_REGEX
name = args.named.first.downcase

View File

@ -13,14 +13,13 @@ module Homebrew
Display the path where <formula> is located.
EOS
switch :verbose
switch :debug
min_named :formula
end
end
def formula
formula_args.parse
args = formula_args.parse
args.formulae_paths.each(&method(:puts))
end

View File

@ -13,7 +13,7 @@ module Homebrew
Install Homebrew's Bundler gems.
EOS
switch :debug
max_named 0
end
end

View File

@ -19,7 +19,7 @@ module Homebrew
def irb_args
# work around IRB modifying ARGV.
Homebrew::CLI::Parser.new(ARGV.dup.freeze) do
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`irb` [<options>]
@ -34,7 +34,7 @@ module Homebrew
end
def irb
irb_args.parse
args = irb_args.parse(ARGV.dup.freeze)
if args.examples?
puts "'v8'.f # => instance of the v8 formula"

View File

@ -24,13 +24,11 @@ module Homebrew
switch "--cached",
description: "Print the cached linkage values stored in `HOMEBREW_CACHE`, set by a previous "\
"`brew linkage` run."
switch :verbose
switch :debug
end
end
def linkage
linkage_args.parse
args = linkage_args.parse
CacheStoreDatabase.use(:linkage) do |db|
kegs = if args.kegs.empty?

View File

@ -36,7 +36,7 @@ module Homebrew
odie "`brew man --link` is now done automatically by `brew update`." if args.link?
Commands.rebuild_internal_commands_completion_list
regenerate_man_pages(args: args)
regenerate_man_pages(preserve_date: args.fail_if_changed?)
if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/Manpage.md", "manpages", "completions"
puts "No changes to manpage or completions output detected."
@ -45,15 +45,15 @@ module Homebrew
end
end
def regenerate_man_pages(args:)
def regenerate_man_pages(preserve_date:)
Homebrew.install_bundler_gems!
markup = build_man_page
convert_man_page(markup, TARGET_DOC_PATH/"Manpage.md", args: args)
convert_man_page(markup, TARGET_MAN_PATH/"brew.1", args: args)
convert_man_page(markup, TARGET_DOC_PATH/"Manpage.md", preserve_date: preserve_date)
convert_man_page(markup, TARGET_MAN_PATH/"brew.1", preserve_date: preserve_date)
cask_markup = (SOURCE_PATH/"brew-cask.1.md").read
convert_man_page(cask_markup, TARGET_MAN_PATH/"brew-cask.1", args: args)
convert_man_page(cask_markup, TARGET_MAN_PATH/"brew-cask.1", preserve_date: preserve_date)
end
def build_man_page
@ -94,14 +94,13 @@ module Homebrew
path.basename.to_s.sub(/\.(rb|sh)$/, "").sub(/^--/, "~~")
end
def convert_man_page(markup, target, args:)
def convert_man_page(markup, target, preserve_date:)
manual = target.basename(".1")
organisation = "Homebrew"
# Set the manpage date to the existing one if we're checking for changes.
# This avoids the only change being e.g. a new date.
date = if args.fail_if_changed? &&
target.extname == ".1" && target.exist?
date = if preserve_date && target.extname == ".1" && target.exist?
/"(\d{1,2})" "([A-Z][a-z]+) (\d{4})" "#{organisation}" "#{manual}"/ =~ target.read
Date.parse("#{Regexp.last_match(1)} #{Regexp.last_match(2)} #{Regexp.last_match(3)}")
else
@ -169,7 +168,7 @@ 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|
next if !long.nil? && cmd_parser.global_option?(cmd_parser.option_to_name(long), desc)
next if !long.nil? && Homebrew::CLI::Parser.global_options.include?([short, long, desc])
generate_option_doc(short, long, desc)
end.reject(&:blank?)
@ -191,7 +190,7 @@ module Homebrew
end
# Omit the common global_options documented separately in the man page.
next if line.match?(/--(debug|force|help|quiet|verbose) /)
next if line.match?(/--(debug|help|quiet|verbose) /)
# Format one option or a comma-separated pair of short and long options.
lines << line.gsub(/^ +(-+[a-z-]+), (-+[a-z-]+) +/, "* `\\1`, `\\2`:\n ")
@ -203,8 +202,7 @@ module Homebrew
def global_options_manpage
lines = ["These options are applicable across multiple subcommands.\n"]
lines += Homebrew::CLI::Parser.global_options.values.map do |names, _, desc|
short, long = names
lines += Homebrew::CLI::Parser.global_options.map do |short, long, desc|
generate_option_doc(short, long, desc)
end
lines.join("\n")

View File

@ -19,8 +19,7 @@ module Homebrew
description: "Upload to the specified Bintray repository (default: `mirror`)."
switch "--no-publish",
description: "Upload to Bintray, but don't publish."
switch :verbose
switch :debug
hide_from_man_page!
min_named :formula
end

View File

@ -25,8 +25,7 @@ module Homebrew
description: "Run `brew pr-publish` on matching pull requests."
switch "--ignore-failures",
description: "Include pull requests that have failing status checks."
switch :verbose
switch :debug
max_named 0
end
end

View File

@ -18,13 +18,13 @@ module Homebrew
description: "Target tap repository (default: `homebrew/core`)."
flag "--workflow=",
description: "Target workflow filename (default: `publish-commit-bottles.yml`)."
switch :verbose
min_named 1
end
end
def pr_publish
pr_publish_args.parse
args = pr_publish_args.parse
tap = Tap.fetch(Homebrew.args.tap || CoreTap.instance.name)
workflow = Homebrew.args.workflow || "publish-commit-bottles.yml"

View File

@ -49,8 +49,7 @@ module Homebrew
flag "--bintray-mirror=",
description: "Use the specified Bintray repository to automatically mirror stable URLs "\
"defined in the formulae (default: `mirror`)."
switch :verbose
switch :debug
min_named 1
end
end
@ -130,7 +129,7 @@ module Homebrew
end
end
def check_branch(path, ref)
def check_branch(path, ref, args:)
branch = Utils.popen_read("git", "-C", path, "symbolic-ref", "--short", "HEAD").strip
return if branch == ref || args.clean? || args.branch_okay?
@ -155,8 +154,8 @@ module Homebrew
else
odebug "Mirroring #{mirror_url}"
mirror_args = ["mirror", f.full_name]
mirror_args << "--debug" if Homebrew.args.debug?
mirror_args << "--verbose" if Homebrew.args.verbose?
mirror_args << "--debug" if args.debug?
mirror_args << "--verbose" if args.verbose?
mirror_args << "--bintray-org=#{org}" if org
mirror_args << "--bintray-repo=#{repo}" if repo
mirror_args << "--no-publish" unless publish
@ -233,7 +232,7 @@ module Homebrew
_, user, repo, pr = *url_match
odie "Not a GitHub pull request: #{arg}" unless pr
check_branch tap.path, "master"
check_branch tap.path, "master", args: args
ohai "Fetching #{tap} pull request ##{pr}"
Dir.mktmpdir pr do |dir|
@ -259,8 +258,8 @@ module Homebrew
next if args.no_upload?
upload_args = ["pr-upload"]
upload_args << "--debug" if Homebrew.args.debug?
upload_args << "--verbose" if Homebrew.args.verbose?
upload_args << "--debug" if args.debug?
upload_args << "--verbose" if args.verbose?
upload_args << "--no-publish" if args.no_publish?
upload_args << "--dry-run" if args.dry_run?
upload_args << "--warn-on-upload-failure" if args.warn_on_upload_failure?

View File

@ -27,8 +27,6 @@ module Homebrew
description: "Upload to the specified Bintray organisation (default: `homebrew`)."
flag "--root-url=",
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
switch :verbose
switch :debug
end
end

View File

@ -37,8 +37,7 @@ module Homebrew
description: "Do not warn if pulling to a branch besides master (useful for testing)."
switch "--no-pbcopy",
description: "Do not copy anything to the system clipboard."
switch :verbose
switch :debug
min_named 1
end
end
@ -48,7 +47,7 @@ module Homebrew
odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase"
pull_args.parse
args = pull_args.parse
# Passthrough Git environment variables for e.g. git am
Utils.set_git_name_email!(author: false, committer: true)

View File

@ -21,7 +21,7 @@ module Homebrew
end
def release_notes
release_notes_args.parse
args = release_notes_args.parse
previous_tag = args.named.first
previous_tag ||= Utils.popen_read(

View File

@ -17,8 +17,6 @@ module Homebrew
description: "Load a library using `require`."
switch "-e",
description: "Execute the given text string as a script."
switch :verbose
switch :debug
end
end

View File

@ -20,8 +20,7 @@ module Homebrew
EOS
flag "--env=",
description: "Use the standard `PATH` instead of superenv's when `std` is passed."
switch :verbose
switch :debug
max_named 0
end
end

View File

@ -29,14 +29,13 @@ module Homebrew
comma_array "--except-cops",
description: "Specify a comma-separated <cops> list to skip checking for violations of the "\
"listed RuboCop cops."
switch :verbose
switch :debug
conflicts "--only-cops", "--except-cops"
end
end
def style
style_args.parse
args = style_args.parse
target = if args.no_named?
nil

View File

@ -13,14 +13,13 @@ module Homebrew
Generate the template files for a new tap.
EOS
switch :verbose
switch :debug
named 1
end
end
def tap_new
tap_new_args.parse
args = tap_new_args.parse
tap_name = args.named.first
tap = Tap.fetch(args.named.first)

View File

@ -27,15 +27,14 @@ module Homebrew
description: "Retain the temporary files created for the test."
switch "--retry",
description: "Retry if a testing fails."
switch :verbose
switch :debug
conflicts "--devel", "--HEAD"
min_named :formula
end
end
def test
test_args.parse
args = test_args.parse
require "formula_assertions"
require "formula_free_port"
@ -110,7 +109,7 @@ module Homebrew
end
end
rescue Exception => e # rubocop:disable Lint/RescueException
retry if retry_test?(f)
retry if retry_test?(f, args: args)
ofail "#{f.full_name}: failed"
puts e, e.backtrace
ensure
@ -119,7 +118,7 @@ module Homebrew
end
end
def retry_test?(f)
def retry_test?(f, args:)
@test_failed ||= Set.new
if args.retry? && @test_failed.add?(f)
oh1 "Testing #{f.full_name} (again)"

View File

@ -29,14 +29,13 @@ module Homebrew
"specific line."
flag "--seed=",
description: "Randomise tests with the specified <value> instead of a random seed."
switch :verbose
switch :debug
max_named 0
end
end
def tests
tests_args.parse
args = tests_args.parse
Homebrew.install_bundler_gems!
gem_user_dir = Gem.user_dir

View File

@ -24,15 +24,14 @@ module Homebrew
"patches for the software."
switch "-f", "--force",
description: "Overwrite the destination directory if it already exists."
switch :verbose
switch :debug
conflicts "--git", "--patch"
min_named :formula
end
end
def unpack
unpack_args.parse
args = unpack_args.parse
formulae = args.formulae
@ -56,12 +55,13 @@ module Homebrew
oh1 "Unpacking #{Formatter.identifier(f.full_name)} to: #{stage_dir}"
ENV["VERBOSE"] = "1" # show messages about tar
# show messages about tar
with_env VERBOSE: "1" do
f.brew do
f.patch if args.patch?
cp_r getwd, stage_dir, preserve: true
end
ENV["VERBOSE"] = nil
end
next unless args.git?

View File

@ -26,7 +26,7 @@ module Homebrew
end
def update_license_data
update_license_data_args.parse
args = update_license_data_args.parse
ohai "Updating SPDX license data..."
latest_tag = GitHub.open_api(SPDX_API_URL)["tag_name"]

View File

@ -21,14 +21,13 @@ module Homebrew
description: "Use the specified <commit> as the start commit."
flag "--before=",
description: "Use the commit at the specified <date> as the start commit."
switch :verbose
switch :debug
max_named 0
end
end
def update_test
update_test_args.parse
args = update_test_args.parse
ENV["HOMEBREW_UPDATE_TEST"] = "1"

View File

@ -13,7 +13,7 @@ module Homebrew
Install and commit Homebrew's vendored gems.
EOS
switch :debug
max_named 0
end
end

View File

@ -1461,14 +1461,16 @@ class Formula
# @private
def self.each
files.each do |file|
yield Formulary.factory(file)
rescue => e
yield begin
Formulary.factory(file)
rescue FormulaUnavailableError => e
# Don't let one broken formula break commands. But do complain.
onoe "Failed to import: #{file}"
puts e
next
end
end
end
# Clear cache of .racks
def self.clear_racks_cache

View File

@ -82,7 +82,7 @@ module Homebrew
end
def args
@args ||= CLI::Args.new(set_default_args: true)
@args ||= CLI::Args.new
end
def messages

View File

@ -40,30 +40,30 @@ module Homebrew
module Help
module_function
def help(cmd = nil, flags = {})
# Resolve command aliases and find file containing the implementation.
path = Commands.path(cmd) if cmd
# Display command-specific (or generic) help in response to `UsageError`.
if (error_message = flags[:usage_error])
$stderr.puts path ? command_help(cmd, path) : HOMEBREW_HELP
$stderr.puts
onoe error_message
exit 1
end
def help(cmd = nil, empty_argv: false, usage_error: nil)
if cmd.nil?
# Handle `brew` (no arguments).
if flags[:empty_argv]
if empty_argv
$stderr.puts HOMEBREW_HELP
exit 1
end
# Handle `brew (-h|--help|--usage|-?|help)` (no other arguments).
if cmd.nil?
puts HOMEBREW_HELP
exit 0
end
# Resolve command aliases and find file containing the implementation.
path = Commands.path(cmd)
# Display command-specific (or generic) help in response to `UsageError`.
if usage_error
$stderr.puts path ? command_help(cmd, path) : HOMEBREW_HELP
$stderr.puts
onoe usage_error
exit 1
end
# Resume execution in `brew.rb` for unknown commands.
return if path.nil?
@ -95,6 +95,8 @@ module Homebrew
cmd_parser = CLI::Parser.from_cmd_path(path)
return unless cmd_parser
# Try parsing arguments here in order to show formula options in help output.
cmd_parser.parse(Homebrew.args.remaining, ignore_invalid_options: true)
cmd_parser.generate_help_text
end

View File

@ -163,6 +163,7 @@ false:
- ./dev-cmd/tests.rb
- ./dev-cmd/unpack.rb
- ./dev-cmd/update-license-data.rb
- ./dev-cmd/update-python-resources.rb
- ./dev-cmd/update-test.rb
- ./dev-cmd/vendor-gems.rb
- ./development_tools.rb
@ -268,6 +269,7 @@ false:
- ./test/ENV_spec.rb
- ./test/bintray_spec.rb
- ./test/bottle_publisher_spec.rb
- ./test/cask_dependent_spec.rb
- ./test/cask/artifact/alt_target_spec.rb
- ./test/cask/artifact/app_spec.rb
- ./test/cask/artifact/binary_spec.rb
@ -823,11 +825,13 @@ false:
- ./test/version_spec.rb
- ./unpack_strategy/uncompressed.rb
- ./utils/gems.rb
- ./utils/pypi.rb
- ./version.rb
true:
- ./build_options.rb
- ./cache_store.rb
- ./cask_dependent.rb
- ./cask/cache.rb
- ./cask/denylist.rb
- ./cask/macos.rb

View File

@ -15,5 +15,7 @@ module Homebrew::CLI
def build_from_source?; end
def named_args; end
def force_bottle?; end
end
end

View File

@ -1,6 +0,0 @@
# This file is autogenerated. Do not edit it by hand. Regenerate it with:
# tapioca sync --exclude json
# typed: true

View File

@ -0,0 +1,7 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `codecov` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true

View File

@ -0,0 +1,7 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `commander` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true

View File

@ -0,0 +1,7 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `highline` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true

View File

@ -0,0 +1,7 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `parlour` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true

View File

@ -1,5 +1,6 @@
# This file is autogenerated. Do not edit it by hand. Regenerate it with:
# tapioca sync --exclude json
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `patchelf` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true
@ -10,15 +11,17 @@ module PatchELF::Helper
private
def aligndown(val, align = _); end
def alignup(val, align = _); end
def aligndown(val, align = T.unsafe(nil)); end
def alignup(val, align = T.unsafe(nil)); end
def color_enabled?; end
def colorize(str, type); end
def self.aligndown(val, align = _); end
def self.alignup(val, align = _); end
def self.color_enabled?; end
def self.colorize(str, type); end
class << self
def aligndown(val, align = T.unsafe(nil)); end
def alignup(val, align = T.unsafe(nil)); end
def color_enabled?; end
def colorize(str, type); end
end
end
PatchELF::Helper::COLOR_CODE = T.let(T.unsafe(nil), Hash)
@ -33,9 +36,11 @@ module PatchELF::Logger
def info(msg); end
def warn(msg); end
def self.error(msg); end
def self.info(msg); end
def self.warn(msg); end
class << self
def error(msg); end
def info(msg); end
def warn(msg); end
end
end
class PatchELF::MM
@ -51,10 +56,10 @@ class PatchELF::MM
private
def abnormal_elf(msg); end
def extend_backward(seg, size = _); end
def extend_forward(seg, size = _); end
def extend_backward(seg, size = T.unsafe(nil)); end
def extend_forward(seg, size = T.unsafe(nil)); end
def fgap_method; end
def find_gap(check_sz: _); end
def find_gap(check_sz: T.unsafe(nil)); end
def invoke_callbacks(seg, start); end
def load_segments; end
def mgap_method; end
@ -73,7 +78,7 @@ class PatchELF::PatchError < ::ELFTools::ELFError
end
class PatchELF::Patcher
def initialize(filename, logging: _); end
def initialize(filename, on_error: T.unsafe(nil), logging: T.unsafe(nil)); end
def add_needed(need); end
def elf; end
@ -87,7 +92,7 @@ class PatchELF::Patcher
def rpath=(rpath); end
def runpath; end
def runpath=(runpath); end
def save(out_file = _); end
def save(out_file = T.unsafe(nil)); end
def soname; end
def soname=(name); end
def use_rpath!; end
@ -97,9 +102,9 @@ class PatchELF::Patcher
def dirty?; end
def dynamic_or_log; end
def interpreter_; end
def log_or_raise(msg, exception = _); end
def log_or_raise(msg, exception = T.unsafe(nil)); end
def needed_; end
def runpath_(rpath_sym = _); end
def runpath_(rpath_sym = T.unsafe(nil)); end
def soname_; end
def tag_name_or_log(type, log_msg); end
end
@ -122,7 +127,7 @@ class PatchELF::Saver
def patch_interpreter; end
def patch_needed; end
def patch_out(out_file); end
def patch_runpath(sym = _); end
def patch_runpath(sym = T.unsafe(nil)); end
def patch_soname; end
def reg_str_table(str, &block); end
def section_header(name); end

View File

@ -13549,6 +13549,94 @@ module ParallelTests
WINDOWS = ::T.let(nil, ::T.untyped)
end
class Parlour::ConflictResolver
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Parlour::Debugging::Tree
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Parlour::Debugging
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::DetachedRbiGenerator
def detached!(*args, &blk); end
end
class Parlour::DetachedRbiGenerator
end
class Parlour::ParseError
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::Plugin
extend ::T::Private::Abstract::Hooks
extend ::T::InterfaceWrapper::Helpers
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator::Namespace
def create_attr(*args, &blk); end
end
class Parlour::RbiGenerator::Options
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator::Parameter
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator::RbiObject
def add_comments(*args, &blk); end
end
class Parlour::RbiGenerator::RbiObject
extend ::T::Private::Abstract::Hooks
extend ::T::InterfaceWrapper::Helpers
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator::StructProp
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Parlour::TypeLoader
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::TypeParser::IntermediateSig
def self.inherited(s); end
end
class Parlour::TypeParser::NodePath
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::TypeParser
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
ParseError = Racc::ParseError
Parser::CurrentRuby = Parser::Ruby26
@ -18883,14 +18971,6 @@ end
module RSpec::Its
end
class RSpec::Mocks::AnyInstance::Recorder
include ::T::CompatibilityPatches::RSpecCompatibility::RecorderExtensions
end
class RSpec::Mocks::MethodDouble
include ::T::CompatibilityPatches::RSpecCompatibility::MethodDoubleExtensions
end
class RSpec::Retry
def attempts(); end
@ -21598,7 +21678,6 @@ module Stdenv
def O3(); end
def Os(); end
end
class String
@ -21895,7 +21974,6 @@ module Superenv
def O3(); end
def Os(); end
end
class SynchronizedDelegator
@ -22566,12 +22644,16 @@ end
class Tapioca::Cli
include ::Thor::Actions
def dsl(*constants); end
def generate(*gems); end
def generator(); end
def init(); end
def require(); end
def sync(); end
def todo(); end
@ -22583,6 +22665,64 @@ end
module Tapioca::Compilers
end
module Tapioca::Compilers::Dsl
end
class Tapioca::Compilers::Dsl::Base
def decorate(*args, &blk); end
def gather_constants(*args, &blk); end
def handles?(*args, &blk); end
def initialize(*args, &blk); end
def processable_constants(*args, &blk); end
SPECIAL_METHOD_NAMES = ::T.let(nil, ::T.untyped)
end
class Tapioca::Compilers::Dsl::Base
extend ::T::Sig
extend ::T::Helpers
extend ::T::Private::Abstract::Hooks
extend ::T::InterfaceWrapper::Helpers
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Tapioca::Compilers::Dsl
end
class Tapioca::Compilers::DslCompiler
def error_handler(*args, &blk); end
def generators(*args, &blk); end
def initialize(*args, &blk); end
def requested_constants(*args, &blk); end
def run(*args, &blk); end
end
class Tapioca::Compilers::DslCompiler
extend ::T::Sig
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Tapioca::Compilers::RequiresCompiler
def compile(*args, &blk); end
def initialize(*args, &blk); end
end
class Tapioca::Compilers::RequiresCompiler
extend ::T::Sig
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Tapioca::Compilers::Sorbet
SORBET = ::T.let(nil, ::T.untyped)
end
@ -22607,6 +22747,7 @@ class Tapioca::Compilers::SymbolTable::SymbolGenerator
def initialize(*args, &blk); end
IGNORED_SYMBOLS = ::T.let(nil, ::T.untyped)
SPECIAL_METHOD_NAMES = ::T.let(nil, ::T.untyped)
TYPE_PARAMETER_MATCHER = ::T.let(nil, ::T.untyped)
end
class Tapioca::Compilers::SymbolTable::SymbolGenerator
@ -22663,6 +22804,8 @@ class Tapioca::Config
def generate_command(); end
def generators(); end
def initialize(*args, &blk); end
def outdir(); end
@ -22676,13 +22819,16 @@ class Tapioca::Config
def todos_path(); end
def typed_overrides(); end
CONFIG_FILE_PATH = ::T.let(nil, ::T.untyped)
DEFAULT_OUTDIR = ::T.let(nil, ::T.untyped)
DEFAULT_DSLDIR = ::T.let(nil, ::T.untyped)
DEFAULT_GEMDIR = ::T.let(nil, ::T.untyped)
DEFAULT_OVERRIDES = ::T.let(nil, ::T.untyped)
DEFAULT_POSTREQUIRE = ::T.let(nil, ::T.untyped)
DEFAULT_RBIDIR = ::T.let(nil, ::T.untyped)
DEFAULT_TODOSPATH = ::T.let(nil, ::T.untyped)
SORBET_CONFIG = ::T.let(nil, ::T.untyped)
SORBET_PATH = ::T.let(nil, ::T.untyped)
TAPIOCA_CONFIG = ::T.let(nil, ::T.untyped)
TAPIOCA_PATH = ::T.let(nil, ::T.untyped)
end
class Tapioca::Config
@ -22757,8 +22903,12 @@ class Tapioca::Gemfile
end
class Tapioca::Generator
def build_dsl(*args, &blk); end
def build_gem_rbis(*args, &blk); end
def build_requires(*args, &blk); end
def build_todos(*args, &blk); end
def config(*args, &blk); end
@ -22778,6 +22928,8 @@ class Tapioca::Loader
def initialize(*args, &blk); end
def load_bundle(*args, &blk); end
def load_rails(*args, &blk); end
end
class Tapioca::Loader
@ -22786,6 +22938,23 @@ class Tapioca::Loader
extend ::T::Private::Methods::SingletonMethodHooks
end
class Tapioca::SorbetConfig
def ignore(); end
def initialize(*args, &blk); end
def paths(*args, &blk); end
end
class Tapioca::SorbetConfig
extend ::T::Sig
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
def self.parse_file(*args, &blk); end
def self.parse_string(*args, &blk); end
end
module Tapioca
end

View File

@ -6,7 +6,6 @@ describe Homebrew::CLI::Parser do
describe "test switch options" do
subject(:parser) {
described_class.new do
switch :verbose, description: "Flag for verbosity"
switch "--more-verbose", description: "Flag for higher verbosity"
switch "--pry", env: :pry
end
@ -16,27 +15,34 @@ describe Homebrew::CLI::Parser do
allow(Homebrew::EnvConfig).to receive(:pry?).and_return(true)
end
context "when `ignore_invalid_options` is true" do
it "passes through invalid options" do
args = parser.parse(["-v", "named-arg", "--not-a-valid-option"], ignore_invalid_options: true)
expect(args.remaining).to eq ["named-arg", "--not-a-valid-option"]
expect(args.named_args).to be_empty
end
end
it "parses short option" do
parser.parse(["-v"])
expect(Homebrew.args).to be_verbose
args = parser.parse(["-v"])
expect(args).to be_verbose
end
it "parses a single valid option" do
parser.parse(["--verbose"])
expect(Homebrew.args).to be_verbose
args = parser.parse(["--verbose"])
expect(args).to be_verbose
end
it "parses a valid option along with few unnamed args" do
args = %w[--verbose unnamed args]
parser.parse(args)
expect(Homebrew.args).to be_verbose
expect(args).to eq %w[--verbose unnamed args]
args = parser.parse(%w[--verbose unnamed args])
expect(args).to be_verbose
expect(args.named).to eq %w[unnamed args]
end
it "parses a single option and checks other options to be nil" do
parser.parse(["--verbose"])
expect(Homebrew.args).to be_verbose
expect(Homebrew.args.more_verbose?).to be nil
args = parser.parse(["--verbose"])
expect(args).to be_verbose
expect(args.more_verbose?).to be nil
end
it "raises an exception and outputs help text when an invalid option is passed" do
@ -45,13 +51,8 @@ describe Homebrew::CLI::Parser do
end
it "maps environment var to an option" do
parser.parse([])
expect(Homebrew.args.pry?).to be true
end
it ":verbose with custom description" do
_, _, _, desc = parser.processed_options.find { |short, _| short == "-v" }
expect(desc).to eq "Flag for verbosity"
args = parser.parse([])
expect(args.pry?).to be true
end
end
@ -64,8 +65,8 @@ describe Homebrew::CLI::Parser do
}
it "parses a long flag option with its argument" do
parser.parse(["--filename=random.txt"])
expect(Homebrew.args.filename).to eq "random.txt"
args = parser.parse(["--filename=random.txt"])
expect(args.filename).to eq "random.txt"
end
it "raises an exception when a flag's required value is not passed" do
@ -73,8 +74,8 @@ describe Homebrew::CLI::Parser do
end
it "parses a comma array flag option" do
parser.parse(["--files=random1.txt,random2.txt"])
expect(Homebrew.args.files).to eq %w[random1.txt random2.txt]
args = parser.parse(["--files=random1.txt,random2.txt"])
expect(args.files).to eq %w[random1.txt random2.txt]
end
end
@ -86,9 +87,9 @@ describe Homebrew::CLI::Parser do
}
it "parses a short flag option with its argument" do
parser.parse(["--filename=random.txt"])
expect(Homebrew.args.filename).to eq "random.txt"
expect(Homebrew.args.f).to eq "random.txt"
args = parser.parse(["--filename=random.txt"])
expect(args.filename).to eq "random.txt"
expect(args.f).to eq "random.txt"
end
end
@ -118,14 +119,14 @@ describe Homebrew::CLI::Parser do
end
it "raises no exception" do
parser.parse(["--flag1=flag1", "--flag2=flag2"])
expect(Homebrew.args.flag1).to eq "flag1"
expect(Homebrew.args.flag2).to eq "flag2"
args = parser.parse(["--flag1=flag1", "--flag2=flag2"])
expect(args.flag1).to eq "flag1"
expect(args.flag2).to eq "flag2"
end
it "raises no exception for optional dependency" do
parser.parse(["--flag3=flag3"])
expect(Homebrew.args.flag3).to eq "flag3"
args = parser.parse(["--flag3=flag3"])
expect(args.flag3).to eq "flag3"
end
end
@ -169,22 +170,22 @@ describe Homebrew::CLI::Parser do
end
it "raises no exception" do
parser.parse(["--switch-a", "--switch-c"])
expect(Homebrew.args.switch_a?).to be true
expect(Homebrew.args.switch_c?).to be true
args = parser.parse(["--switch-a", "--switch-c"])
expect(args.switch_a?).to be true
expect(args.switch_c?).to be true
end
it "raises no exception for optional dependency" do
parser.parse(["--switch-b"])
expect(Homebrew.args.switch_b?).to be true
args = parser.parse(["--switch-b"])
expect(args.switch_b?).to be true
end
it "prioritizes cli arguments over env vars when they conflict" do
allow(Homebrew::EnvConfig).to receive(:switch_a?).and_return(true)
allow(Homebrew::EnvConfig).to receive(:switch_b?).and_return(false)
parser.parse(["--switch-b"])
expect(Homebrew.args.switch_a).to be_falsy
expect(Homebrew.args).to be_switch_b
args = parser.parse(["--switch-b"])
expect(args.switch_a).to be_falsy
expect(args).to be_switch_b
end
it "raises an exception on constraint violation when both are env vars" do
@ -214,38 +215,32 @@ describe Homebrew::CLI::Parser do
switch "--foo"
flag "--bar"
switch "-s"
switch :verbose
end
}
it "#options_only" do
parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"])
expect(Homebrew.args.options_only).to eq %w[--foo --bar=value -s --verbose]
args = parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"])
expect(args.options_only).to eq %w[--verbose --foo --bar=value -s]
end
it "#flags_only" do
parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"])
expect(Homebrew.args.flags_only).to eq %w[--foo --bar=value --verbose]
end
it "#passthrough" do
parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"])
expect(Homebrew.args.passthrough).to eq %w[--foo --bar=value -s]
args = parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"])
expect(args.flags_only).to eq %w[--verbose --foo --bar=value]
end
it "#formulae raises an error when a Formula is unavailable" do
parser.parse(["mxcl"])
expect { Homebrew.args.formulae }.to raise_error FormulaUnavailableError
args = parser.parse(["mxcl"])
expect { args.formulae }.to raise_error FormulaUnavailableError
end
it "#formulae returns an empty array when there are no Formulae" do
parser.parse([])
expect(Homebrew.args.formulae).to be_empty
args = parser.parse([])
expect(args.formulae).to be_empty
end
it "#casks returns an empty array when there are no matching casks" do
parser.parse([])
expect(Homebrew.args.casks).to eq []
args = parser.parse([])
expect(args.casks).to eq []
end
context "kegs" do
@ -255,24 +250,24 @@ describe Homebrew::CLI::Parser do
end
it "when there are matching kegs returns an array of Kegs" do
parser.parse(["mxcl"])
expect(Homebrew.args.kegs.length).to eq 1
args = parser.parse(["mxcl"])
expect(args.kegs.length).to eq 1
end
it "when there are no matching kegs returns an array of Kegs" do
parser.parse([])
expect(Homebrew.args.kegs).to be_empty
args = parser.parse([])
expect(args.kegs).to be_empty
end
end
it "#named returns an array of non-option arguments" do
parser.parse(["foo", "-v", "-s"])
expect(Homebrew.args.named).to eq ["foo"]
args = parser.parse(["foo", "-v", "-s"])
expect(args.named).to eq ["foo"]
end
it "#named returns an empty array when there are no named arguments" do
parser.parse([])
expect(Homebrew.args.named).to be_empty
args = parser.parse([])
expect(args.named).to be_empty
end
end
end

View File

@ -14,7 +14,8 @@ shared_examples "parseable arguments" do
it "can parse arguments" do
require "dev-cmd/#{command_name}" unless require? "cmd/#{command_name}"
expect { Homebrew.send(method_name).parse({}, allow_no_named_args: true) }
.not_to raise_error
parser = Homebrew.public_send(method_name)
expect(parser).to respond_to(:parse)
end
end

View File

@ -50,7 +50,7 @@ describe FormulaInstaller do
specify "basic bottle install" do
allow(DevelopmentTools).to receive(:installed?).and_return(false)
Homebrew.install_args.parse("testball_bottle")
Homebrew.install_args.parse(["testball_bottle"])
temporarily_install_bottle(TestballBottle.new) do |f|
# Copied directly from formula_installer_spec.rb
# as we expect the same behavior.

View File

@ -7,7 +7,21 @@ module PyPI
@pipgrip_installed = nil
# Get name, url, and version for a given pypi package
def url_to_pypi_package_name(url)
return unless url.start_with? PYTHONHOSTED_URL_PREFIX
File.basename(url).match(/^(.+)-[a-z\d.]+$/)[1]
end
def update_pypi_url(url, version)
package = url_to_pypi_package_name url
return if package.nil?
_, url = get_pypi_info(package, version)
url
end
# Get name, url and sha256 for a given pypi package
def get_pypi_info(package, version)
metadata_url = "https://pypi.org/pypi/#{package}/#{version}/json"
out, _, status = curl_output metadata_url, "--location"
@ -21,18 +35,17 @@ module PyPI
end
sdist = json["urls"].find { |url| url["packagetype"] == "sdist" }
return json["info"]["name"] if sdist.nil?
[json["info"]["name"], sdist["url"], sdist["digests"]["sha256"]]
end
def update_python_resources!(formula, version = nil, print_only: false, silent: false,
ignore_non_pypi_packages: false)
@pipgrip_installed ||= Formula["pipgrip"].any_version_installed?
odie '"pipgrip" must be installed (`brew install pipgrip`)' unless @pipgrip_installed
# PyPI package name isn't always the same as the formula name. Try to infer from the URL.
pypi_name = if formula.stable.url.start_with?(PYTHONHOSTED_URL_PREFIX)
File.basename(formula.stable.url).match(/^(.+)-[a-z\d.]+$/)[1]
url_to_pypi_package_name formula.stable.url
else
formula.name
end
@ -52,12 +65,17 @@ module PyPI
odie "\"#{formula.name}\" contains non-PyPI resources. Please update the resources manually."
end
@pipgrip_installed ||= Formula["pipgrip"].any_version_installed?
odie '"pipgrip" must be installed (`brew install pipgrip`)' unless @pipgrip_installed
ohai "Retrieving PyPI dependencies for \"#{pypi_name}==#{version}\"" if !print_only && !silent
pipgrip_output = Utils.popen_read Formula["pipgrip"].bin/"pipgrip", "--json", "#{pypi_name}==#{version}"
pipgrip_output = Utils.popen_read Formula["pipgrip"].bin/"pipgrip", "--json", "--no-cache-dir",
"#{pypi_name}==#{version}"
unless $CHILD_STATUS.success?
odie <<~EOS
Unable to determine dependencies for \"#{pypi_name}\" because of a failure when running
`pipgrip --json #{pypi_name}==#{version}`. Please update the resources for \"#{formula.name}\" manually.
`pipgrip --json --no-cache-dir #{pypi_name}==#{version}`.
Please update the resources for \"#{formula.name}\" manually.
EOS
end

View File

@ -312,8 +312,10 @@ no formula is provided.
Also print diffstat from commit.
* `--oneline`:
Print only one line per commit.
* `-1`, `--max-count`:
Print only one or a specified number of commits.
* `-1`:
Print only one commit.
* `-n`, `--max-count`:
Print only a specified number of commits.
### `migrate` [*`options`*] *`formula`*
@ -525,6 +527,8 @@ Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1)
Use `git merge` to apply updates (rather than `git rebase`).
* `--preinstall`:
Run on auto-updates (e.g. before `brew install`). Skips some slower steps.
* `-f`, `--force`:
Always do a slower, full update check (even if unnecessary).
### `update-reset` [*`repository`*]

View File

@ -428,8 +428,12 @@ Also print diffstat from commit\.
Print only one line per commit\.
.
.TP
\fB\-1\fR, \fB\-\-max\-count\fR
Print only one or a specified number of commits\.
\fB\-1\fR
Print only one commit\.
.
.TP
\fB\-n\fR, \fB\-\-max\-count\fR
Print only a specified number of commits\.
.
.SS "\fBmigrate\fR [\fIoptions\fR] \fIformula\fR"
Migrate renamed packages to new names, where \fIformula\fR are old names of packages\.
@ -682,6 +686,10 @@ Use \fBgit merge\fR to apply updates (rather than \fBgit rebase\fR)\.
\fB\-\-preinstall\fR
Run on auto\-updates (e\.g\. before \fBbrew install\fR)\. Skips some slower steps\.
.
.TP
\fB\-f\fR, \fB\-\-force\fR
Always do a slower, full update check (even if unnecessary)\.
.
.SS "\fBupdate\-reset\fR [\fIrepository\fR]"
Fetch and reset Homebrew and all tap repositories (or any specified \fIrepository\fR) using \fBgit\fR(1) to their latest \fBorigin/master\fR\.
.