Merge remote-tracking branch 'origin/master' into add_change_origin_command

This commit is contained in:
Mike McQuaid 2019-12-30 10:39:28 +00:00
commit cfe2f5bfda
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
485 changed files with 843 additions and 631 deletions

View File

@ -1,33 +0,0 @@
# Comment that will be sent if an issue is judged to be closed
comment: |
Whoops, it looks like you created an issue without filling out the checklist and providing all the needed information from one of the issue templates: <https://github.com/Homebrew/brew/issues/new/choose>
As we need all this information to help you we're closing this issue. If you add the necessary information to this issue (**don't create a new or duplicate issue, please**) and comment to let us know, a Homebrew maintainer will check it out when they get the chance. If it's deemed to be a valid issue then this issue may be reopened.
Sorry!
issueConfigs:
# There can be several configs for different kind of issues.
- content:
# new feature suggestion
- "A detailed description of the proposed feature"
- "The motivation for the feature"
- "How the feature would be relevant to at least 90% of Homebrew users"
- "What alternatives to the feature have been considered"
- content:
# reproducible bug report
- "are reporting a bug others will be able to reproduce"
- "reproduced the problem with multiple formulae"
- "brew update"
- "brew doctor"
- "brew config"
- "What you were trying to do (and why)"
- "What happened (include command output)"
- "What you expected to happen"
- "Step-by-step reproduction instructions (by running `brew` commands)"
# Optional configuration:
#
# whether the keywords are case-insensitive
# default value is false, which means keywords are case-sensitive
caseInsensitive: false
# The issue is judged to be legal if it includes all keywords from any of these two configs.
# Or it will be closed by the app.

View File

@ -11,15 +11,25 @@ jobs:
os: [ubuntu-latest, macOS-latest]
steps:
- name: Set up Git repository
uses: actions/checkout@master
uses: actions/checkout@v1
- name: Set up Homebrew
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew
sudo mkdir -p /home/linuxbrew
sudo ln -s "$PWD" "$HOMEBREW_REPOSITORY"
HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew
sudo mkdir -p /home/linuxbrew/.linuxbrew
cd ..
sudo mv "brew" "$HOMEBREW_REPOSITORY"
sudo ln -s "$HOMEBREW_REPOSITORY" "brew"
cd /home/linuxbrew/.linuxbrew
sudo mkdir -p bin etc include lib opt sbin share var/homebrew/linked Cellar
sudo ln -s ../Homebrew/bin/brew /home/linuxbrew/.linuxbrew/bin/
sudo chown -R "$USER" /home/linuxbrew
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
# Install taps needed for 'brew tests'
export HOMEBREW_NO_AUTO_UPDATE=1
brew tap homebrew/bundle
else
HOMEBREW_REPOSITORY="$(brew --repo)"
mv "$HOMEBREW_REPOSITORY/Library/Taps" "$PWD/Library"
@ -28,11 +38,30 @@ jobs:
brew update-reset Library/Taps/homebrew/homebrew-core
# Install taps needed for 'brew tests'
export HOMEBREW_NO_AUTO_UPDATE=1
brew tap homebrew/cask
brew tap homebrew/bundle
brew tap homebrew/services
fi
- name: Run brew config
run: |
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew config
- name: Run brew doctor
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/bin:/bin"
# Cleanup some Linux `brew doctor` failures
sudo rm -rf /usr/local/include/node/
else
# Allow Xcode to be outdated
export HOMEBREW_GITHUB_ACTIONS=1
fi
brew doctor
- name: Install Bundler RubyGems
run: |
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
@ -101,6 +130,12 @@ jobs:
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew readall --aliases
- name: Run vale for docs linting
run: |
export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin"
brew install vale
vale $(brew --repo)/docs/
- name: Build Docker image
run: |
docker pull homebrew/brew

1
.gitignore vendored
View File

@ -154,6 +154,7 @@
!/.editorconfig
!/.gitignore
!/.yardopts
!/.vale.ini
!/CHANGELOG.md
!/CONTRIBUTING.md
!/Dockerfile

4
.vale.ini Normal file
View File

@ -0,0 +1,4 @@
StylesPath = ./docs/vale-styles
[*.md]
BasedOnStyles = Homebrew

View File

@ -79,7 +79,7 @@ Metrics/PerceivedComplexity:
Enabled: false
# GitHub diff UI wraps beyond 118 characters (so that's the goal)
Metrics/LineLength:
Layout/LineLength:
Max: 170
# ignore manpage comments and long single-line strings
IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options :']

View File

@ -33,7 +33,7 @@ Layout/FirstHashElementIndentation:
EnforcedStyle: align_braces
# Casks often contain long URLs and file paths.
Metrics/LineLength:
Layout/LineLength:
Enabled: false
# Casks don't need documentation.

View File

@ -62,7 +62,7 @@ Metrics/PerceivedComplexity:
Max: 100
# GitHub diff UI wraps beyond 118 characters
Metrics/LineLength:
Layout/LineLength:
Max: 118
# ignore manpage comments
IgnoredPatterns: ['#: ']

View File

@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.1)
activesupport (6.0.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
@ -26,7 +26,7 @@ GEM
i18n (1.7.0)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
json (2.2.0)
json (2.3.0)
mechanize (2.7.6)
domain_name (~> 0.5, >= 0.5.1)
http-cookie (~> 1.0)
@ -36,22 +36,22 @@ GEM
nokogiri (~> 1.6)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
mime-types (3.3)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
minitest (5.13.0)
mustache (1.1.0)
mustache (1.1.1)
net-http-digest_auth (1.4.1)
net-http-persistent (3.1.0)
connection_pool (~> 2.2)
nokogiri (1.10.5)
nokogiri (1.10.7)
mini_portile2 (~> 2.4.0)
ntlm-http (0.1.1)
parallel (1.19.1)
parallel_tests (2.29.2)
parallel_tests (2.30.0)
parallel
parser (2.6.5.0)
parser (2.7.0.0)
ast (~> 2.4.0)
plist (3.5.0)
rainbow (3.0.0)
@ -64,8 +64,8 @@ GEM
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.0)
rspec-support (~> 3.9.0)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
@ -77,19 +77,19 @@ GEM
rspec-support (~> 3.9.0)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.9.0)
rspec-support (3.9.1)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
rubocop (0.77.0)
rubocop (0.78.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.5.1)
rubocop-performance (1.5.2)
rubocop (>= 0.71.0)
rubocop-rspec (1.37.0)
rubocop-rspec (1.37.1)
rubocop (>= 0.68.1)
ruby-macho (2.2.0)
ruby-progressbar (1.10.1)
@ -100,10 +100,10 @@ GEM
simplecov-html (0.10.2)
term-ansicolor (1.7.1)
tins (~> 1.0)
thor (0.20.3)
thor (1.0.1)
thread_safe (0.3.6)
tins (1.22.2)
tzinfo (1.2.5)
tzinfo (1.2.6)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext

View File

@ -77,8 +77,8 @@ HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty --abbr
HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION"
if [[ -z "$HOMEBREW_VERSION" ]]
then
HOMEBREW_VERSION=">=1.7.1 (shallow or no git repository)"
HOMEBREW_USER_AGENT_VERSION="1.X.Y"
HOMEBREW_VERSION=">=2.2.0 (shallow or no git repository)"
HOMEBREW_USER_AGENT_VERSION="2.X.Y"
fi
if [[ "$HOMEBREW_PREFIX" = "/" || "$HOMEBREW_PREFIX" = "/usr" ]]
@ -410,8 +410,8 @@ fi
check-run-command-as-root() {
[[ "$(id -u)" = 0 ]] || return
# Allow Azure Pipelines/Docker/Kubernetes to do everything as root (as it's normal there)
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|docker|kubepods" -q /proc/1/cgroup && return
# Allow Azure Pipelines/Docker/Concourse/Kubernetes to do everything as root (as it's normal there)
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|docker|garden|kubepods" -q /proc/1/cgroup && return
# Homebrew Services may need `sudo` for system-wide daemons.
[[ "$HOMEBREW_COMMAND" = "services" ]] && return

View File

@ -127,7 +127,7 @@ class Build
end
if ARGV.interactive?
ohai "Entering interactive mode"
puts "Type `exit` to return and finalize the installation"
puts "Type `exit` to return and finalize the installation."
puts "Install to this prefix: #{formula.prefix}"
if ARGV.git?

View File

@ -11,7 +11,7 @@ module Cask
DIVIDER_REGEX = /(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join('|')})/.freeze
MAJOR_MINOR_PATCH_REGEX = /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/.freeze
MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:\.([^.,:]+)(?:\.([^.,:]+))?)?/.freeze
INVALID_CHARACTERS = /[^0-9a-zA-Z\.\,\:\-\_]/.freeze

View File

@ -111,7 +111,7 @@ class Cleaner
end
if ARGV.debug?
old_perms = path.stat.mode & 0777
puts "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}" if perms != old_perms
odebug "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}" if perms != old_perms
end
path.chmod perms
end

View File

@ -5,16 +5,23 @@ require "ostruct"
module Homebrew
module CLI
class Args < OpenStruct
attr_accessor :processed_options
attr_reader :processed_options, :args_parsed
# undefine tap to allow --tap argument
undef tap
def initialize(argv:)
super
@argv = argv
@args_parsed = false
@processed_options = []
end
def freeze_processed_options!(processed_options)
@processed_options += processed_options
@processed_options.freeze
@args_parsed = true
end
def option_to_name(option)
option.sub(/\A--?/, "")
.tr("-", "_")
@ -51,22 +58,38 @@ module Homebrew
options_only - CLI::Parser.global_options.values.map(&:first).flatten
end
def downcased_unique_named
# Only lowercase names, not paths, bottle filenames or URLs
@downcased_unique_named ||= remaining.map do |arg|
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
arg
def named
return [] if remaining.nil?
remaining
end
def formulae
require "formula"
@formulae ||= (downcased_unique_named - casks).map do |name|
if name.include?("/") || File.exist?(name)
Formulary.factory(name, spec)
else
arg.downcase
Formulary.find_with_priority(name, spec)
end
end.uniq
end.uniq(&:name)
end
def resolved_formulae
require "formula"
@resolved_formulae ||= (downcased_unique_named - casks).map do |name|
Formulary.resolve(name, spec: spec(nil))
end.uniq(&:name)
end
def casks
@casks ||= downcased_unique_named.grep HOMEBREW_CASK_TAP_CASK_REGEX
end
def kegs
require "keg"
require "formula"
require "missing_formula"
@kegs ||= downcased_unique_named.map do |name|
raise UsageError if name.empty?
@ -113,6 +136,42 @@ module Homebrew
end
end
end
private
def downcased_unique_named
# Only lowercase names, not paths, bottle filenames or URLs
arguments = if args_parsed
remaining
else
cmdline_args.reject { |arg| arg.start_with?("-") }
end
arguments.map do |arg|
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
arg
else
arg.downcase
end
end.uniq
end
def head
(args_parsed && HEAD?) || cmdline_args.include?("--HEAD")
end
def devel
(args_parsed && devel?) || cmdline_args.include?("--devel")
end
def spec(default = :stable)
if head
:head
elsif devel
:devel
else
default
end
end
end
end
end

View File

@ -13,7 +13,7 @@ module Homebrew
attr_reader :processed_options, :hide_from_man_page
def self.parse(args = ARGV, &block)
new(&block).parse(args)
new(args, &block).parse(args)
end
def self.global_options
@ -25,13 +25,16 @@ module Homebrew
}
end
def initialize(&block)
def initialize(args = ARGV, &block)
@parser = OptionParser.new
@args = Homebrew::CLI::Args.new(argv: ARGV_WITHOUT_MONKEY_PATCHING)
@args[:remaining] = []
@args[:cmdline_args] = args.dup
@constraints = []
@conflicts = []
@switch_sources = {}
@processed_options = []
@max_named_args = nil
@hide_from_man_page = false
instance_eval(&block)
post_initialize
@ -137,11 +140,12 @@ module Homebrew
raise e
end
check_constraint_violations
check_named_args(remaining_args)
@args[:remaining] = remaining_args
@args_parsed = true
@args.processed_options = @processed_options
@args.freeze_processed_options!(@processed_options)
Homebrew.args = @args
cmdline_args.freeze
@args_parsed = true
@parser
end
@ -159,7 +163,7 @@ module Homebrew
end
def formula_options
ARGV.formulae.each do |f|
@args.formulae.each do |f|
next if f.options.empty?
f.options.each do |o|
@ -176,6 +180,10 @@ module Homebrew
[]
end
def max_named(count)
@max_named_args = count
end
def hide_from_man_page!
@hide_from_man_page = true
end
@ -267,6 +275,10 @@ module Homebrew
check_constraints
end
def check_named_args(args)
raise NamedArgumentsError, @max_named_args if !@max_named_args.nil? && args.size > @max_named_args
end
def process_option(*args)
option, = @parser.make_switch(args)
@processed_options << [option.short.first, option.long.first, option.arg, option.desc.first]
@ -275,14 +287,10 @@ module Homebrew
class OptionConstraintError < RuntimeError
def initialize(arg1, arg2, missing: false)
if !missing
message = <<~EOS
`#{arg1}` and `#{arg2}` should be passed together.
EOS
message = if !missing
"`#{arg1}` and `#{arg2}` should be passed together."
else
message = <<~EOS
`#{arg2}` cannot be passed without `#{arg1}`.
EOS
"`#{arg2}` cannot be passed without `#{arg1}`."
end
super message
end
@ -292,17 +300,27 @@ module Homebrew
def initialize(args)
args_list = args.map(&Formatter.public_method(:option))
.join(" and ")
super <<~EOS
Options #{args_list} are mutually exclusive.
EOS
super "Options #{args_list} are mutually exclusive."
end
end
class InvalidConstraintError < RuntimeError
def initialize(arg1, arg2)
super <<~EOS
`#{arg1}` and `#{arg2}` cannot be mutually exclusive and mutually dependent simultaneously.
EOS
super "`#{arg1}` and `#{arg2}` cannot be mutually exclusive and mutually dependent simultaneously."
end
end
class NamedArgumentsError < UsageError
def initialize(maximum)
message = case maximum
when 0
"This command does not take named arguments."
when 1
"This command does not take multiple named arguments."
else
"This command does not take more than #{maximum} named arguments."
end
super message
end
end
end

View File

@ -29,7 +29,7 @@ module Homebrew
if ARGV.named.empty?
puts HOMEBREW_CACHE
else
ARGV.formulae.each do |f|
Homebrew.args.formulae.each do |f|
if Fetch.fetch_bottle?(f)
puts f.bottle.cached_download
else

View File

@ -22,7 +22,7 @@ module Homebrew
def __cellar
__cellar_args.parse
if ARGV.named.empty?
if Homebrew.args.named.blank?
puts HOMEBREW_CELLAR
else
puts ARGV.resolved_formulae.map(&:rack)

View File

@ -11,7 +11,7 @@ module Homebrew
def __env_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`--env` [<options>]
`--env` [<options>] [<formula>]
Summarise Homebrew's build environment as a plain list.
@ -30,7 +30,7 @@ module Homebrew
__env_args.parse
ENV.activate_extensions!
ENV.deps = ARGV.formulae if superenv?
ENV.deps = Homebrew.args.formulae if superenv?
ENV.setup_build_environment
ENV.universal_binary if ARGV.build_universal?

View File

@ -22,7 +22,7 @@ module Homebrew
def __prefix
__prefix_args.parse
if ARGV.named.empty?
if Homebrew.args.named.blank?
puts HOMEBREW_PREFIX
else
puts ARGV.resolved_formulae.map { |f|

View File

@ -13,14 +13,13 @@ module Homebrew
Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask
(if tapped) to standard output.
EOS
max_named 0
end
end
def __version
__version_args.parse
odie "This command does not take arguments." if ARGV.any?
puts "Homebrew #{HOMEBREW_VERSION}"
puts "#{CoreTap.instance.full_name} #{CoreTap.instance.version_string}"
puts "#{Tap.default_cask_tap.full_name} #{Tap.default_cask_tap.version_string}" if Tap.default_cask_tap.installed?

View File

@ -19,14 +19,13 @@ module Homebrew
EOS
switch :verbose
switch :debug
max_named 1
end
end
def analytics
analytics_args.parse
raise UsageError if args.remaining.size > 1
case args.remaining.first
when nil, "state"
if Utils::Analytics.disabled?
@ -42,7 +41,7 @@ module Homebrew
when "regenerate-uuid"
Utils::Analytics.regenerate_uuid!
else
raise UsageError
raise UsageError, "Unknown subcommand."
end
end
end

View File

@ -12,17 +12,17 @@ module Homebrew
Display the source of <formula>.
EOS
max_named 1
end
end
def cat
cat_args.parse
# do not "fix" this to support multiple arguments, the output would be
# unparsable, if the user wants to cat multiple formula they can call
# brew cat multiple times.
formulae = ARGV.formulae
# unparsable; if the user wants to cat multiple formula they can call
# `brew cat` multiple times.
formulae = Homebrew.args.formulae
raise FormulaUnspecifiedError if formulae.empty?
raise "`brew cat` doesn't support multiple arguments" if args.remaining.size > 1
cd HOMEBREW_REPOSITORY
pager = if ENV["HOMEBREW_BAT"].nil?

View File

@ -21,7 +21,7 @@ module Homebrew
description: "Show what would be removed, but do not actually remove anything."
switch "-s",
description: "Scrub the cache, including downloads for even the latest versions. "\
"Note downloads for any installed formula or cask will still not be deleted. "\
"Note downloads for any installed formulae or casks will still not be deleted. "\
"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."

View File

@ -20,17 +20,18 @@ module Homebrew
def command
command_args.parse
abort "This command requires a command argument" if args.remaining.empty?
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(args.remaining.first, args.remaining.first)
raise UsageError, "This command requires a command argument" if args.remaining.empty?
path = Commands.path(cmd)
args.remaining.each do |c|
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(c, c)
path = Commands.path(cmd)
cmd_paths = PATH.new(ENV["PATH"]).append(Tap.cmd_directories) unless path
path ||= which("brew-#{cmd}", cmd_paths)
path ||= which("brew-#{cmd}.rb", cmd_paths)
cmd_paths = PATH.new(ENV["PATH"]).append(Tap.cmd_directories) unless path
path ||= which("brew-#{cmd}", cmd_paths)
path ||= which("brew-#{cmd}.rb", cmd_paths)
odie "Unknown command: #{cmd}" unless path
puts path
odie "Unknown command: #{cmd}" unless path
puts path
end
end
end

View File

@ -19,6 +19,7 @@ module Homebrew
description: "Include aliases of internal commands."
switch :verbose
switch :debug
max_named 0
end
end
@ -35,21 +36,18 @@ module Homebrew
end
# Find commands in Homebrew/cmd
puts "Built-in commands"
puts Formatter.columns(internal_commands.sort)
ohai "Built-in commands", Formatter.columns(internal_commands.sort)
# Find commands in Homebrew/dev-cmd
puts
puts "Built-in developer commands"
puts Formatter.columns(internal_developer_commands.sort)
ohai "Built-in developer commands", Formatter.columns(internal_developer_commands.sort)
exts = external_commands
return if exts.empty?
# Find commands in the PATH
puts
puts "External commands"
puts Formatter.columns(exts)
ohai "External commands", Formatter.columns(exts)
end
def internal_commands

View File

@ -16,12 +16,12 @@ module Homebrew
EOS
switch :verbose
switch :debug
max_named 0
end
end
def config
config_args.parse
raise UsageError unless args.remaining.empty?
SystemConfig.dump_verbose_config
end

View File

@ -67,16 +67,16 @@ module Homebrew
if args.installed?
puts_deps_tree Formula.installed.sort, recursive
else
raise FormulaUnspecifiedError if args.remaining.empty?
raise FormulaUnspecifiedError if Homebrew.args.remaining.empty?
puts_deps_tree ARGV.formulae, recursive
puts_deps_tree Homebrew.args.formulae, recursive
end
return
elsif args.all?
puts_deps Formula.sort, recursive
return
elsif !args.remaining.empty? && args.for_each?
puts_deps ARGV.formulae, recursive
elsif !Homebrew.args.remaining.empty? && args.for_each?
puts_deps Homebrew.args.formulae, recursive
return
end
@ -88,14 +88,14 @@ module Homebrew
!args.include_optional? &&
!args.skip_recommended?
if args.remaining.empty?
if Homebrew.args.remaining.empty?
raise FormulaUnspecifiedError unless args.installed?
puts_deps Formula.installed.sort, recursive
return
end
all_deps = deps_for_formulae(ARGV.formulae, recursive, &(args.union? ? :| : :&))
all_deps = deps_for_formulae(Homebrew.args.formulae, recursive, &(args.union? ? :| : :&))
all_deps = condense_requirements(all_deps)
all_deps.select!(&:installed?) if args.installed?
all_deps.map!(&method(:dep_display_name))
@ -175,13 +175,11 @@ module Homebrew
end
def recursive_deps_tree(f, prefix, recursive)
reqs = f.requirements
deps = f.deps
includes, ignores = argv_includes_ignores(ARGV)
deps = reject_ignores(f.deps, ignores, includes)
reqs = reject_ignores(f.requirements, ignores, includes)
dependables = reqs + deps
dependables.reject!(&:optional?) unless args.include_optional?
dependables.reject!(&:build?) unless args.include_build?
dependables.reject!(&:test?) unless args.include_test?
dependables.reject!(&:recommended?) if args.skip_recommended?
max = dependables.length - 1
@dep_stack.push f.name
dependables.each_with_index do |dep, i|

View File

@ -40,17 +40,13 @@ module Homebrew
search_type << :either if args.search
search_type << :name if args.name
search_type << :desc if args.description
if search_type.size > 1
odie "Pick one, and only one, of -s/--search, -n/--name, or -d/--description."
elsif search_type.present? && ARGV.named.empty?
odie "You must provide a search term."
end
odie "You must provide a search term." if search_type.present? && ARGV.named.empty?
results = if search_type.empty?
raise FormulaUnspecifiedError if ARGV.named.empty?
desc = {}
ARGV.formulae.each { |f| desc[f.full_name] = f.desc }
Homebrew.args.formulae.each { |f| desc[f.full_name] = f.desc }
Descriptions.new(desc)
else
arg = ARGV.named.join(" ")

View File

@ -21,6 +21,7 @@ module Homebrew
description: "Explicitly set the <version> of the package being installed."
switch :verbose
switch :debug
max_named 0
end
end
@ -47,7 +48,6 @@ module Homebrew
def detect_version(path)
version = path.version.to_s
raise "Couldn't determine version, set it with --version=<version>" if version.empty?
version

View File

@ -18,7 +18,8 @@ module Homebrew
an issue; just ignore this.
EOS
switch "--list-checks",
description: "List all audit methods."
description: "List all audit methods, which can be run individually "\
"if provided as arguments."
switch "-D", "--audit-debug",
description: "Enable debugging and profiling of audit methods."
switch :verbose
@ -50,7 +51,7 @@ module Homebrew
first_warning = true
methods.each do |method|
$stderr.puts "Checking #{method}" if args.debug?
$stderr.puts Formatter.headline("Checking #{method}", color: :magenta) if args.debug?
unless checks.respond_to?(method)
Homebrew.failed = true
puts "No check available by the name: #{method}"

View File

@ -49,13 +49,13 @@ module Homebrew
if args.deps?
bucket = []
ARGV.formulae.each do |f|
Homebrew.args.formulae.each do |f|
bucket << f
bucket.concat f.recursive_dependencies.map(&:to_formula)
end
bucket.uniq!
else
bucket = ARGV.formulae
bucket = Homebrew.args.formulae
end
puts "Fetching: #{bucket * ", "}" if bucket.size > 1

View File

@ -28,6 +28,7 @@ module Homebrew
"be accessible with its link."
switch :verbose
switch :debug
max_named 1
end
end

View File

@ -23,7 +23,7 @@ module Homebrew
if args.remaining.empty?
exec_browser HOMEBREW_WWW
else
exec_browser(*ARGV.formulae.map(&:homepage))
exec_browser(*Homebrew.args.formulae.map(&:homepage))
end
end
end

View File

@ -61,33 +61,39 @@ module Homebrew
def info
info_args.parse
if args.days.present?
raise UsageError, "days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days)
raise UsageError, "--days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days)
end
if args.category.present?
if ARGV.named.present? && !VALID_FORMULA_CATEGORIES.include?(args.category)
raise UsageError, "category must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae"
if Homebrew.args.named.present? && !VALID_FORMULA_CATEGORIES.include?(args.category)
raise UsageError, "--category must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae"
end
unless VALID_CATEGORIES.include?(args.category)
raise UsageError, "category must be one of #{VALID_CATEGORIES.join(", ")}"
raise UsageError, "--category must be one of #{VALID_CATEGORIES.join(", ")}"
end
end
if args.json
raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
if !(args.all? || args.installed?) && Homebrew.args.named.blank?
raise UsageError, "This command's option requires a formula argument"
end
print_json
elsif args.github?
exec_browser(*ARGV.formulae.map { |f| github_info(f) })
raise UsageError, "This command's option requires a formula argument" if Homebrew.args.named.blank?
exec_browser(*Homebrew.args.formulae.map { |f| github_info(f) })
else
print_info
end
end
def print_info
if ARGV.named.empty?
if Homebrew.args.named.blank?
if args.analytics?
Utils::Analytics.output
elsif HOMEBREW_CELLAR.exist?
@ -95,7 +101,7 @@ module Homebrew
puts "#{count} #{"keg".pluralize(count)}, #{HOMEBREW_CELLAR.dup.abv}"
end
else
ARGV.named.each_with_index do |f, i|
Homebrew.args.named.each_with_index do |f, i|
puts unless i.zero?
begin
formula = if f.include?("/") || File.exist?(f)
@ -129,7 +135,7 @@ module Homebrew
elsif args.installed?
Formula.installed.sort
else
ARGV.formulae
Homebrew.args.formulae
end
json = ff.map(&:to_hash)
puts JSON.generate(json)

View File

@ -92,7 +92,9 @@ module Homebrew
end
def install
ARGV.named.each do |name|
install_args.parse
Homebrew.args.named.each do |name|
next if File.exist?(name)
next if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
@ -100,7 +102,6 @@ module Homebrew
tap.install unless tap.installed?
end
install_args.parse
raise FormulaUnspecifiedError if args.remaining.empty?
if args.ignore_dependencies?
@ -130,7 +131,7 @@ module Homebrew
# developer tools are available, we need to stop them early on
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
ARGV.formulae.each do |f|
Homebrew.args.formulae.each do |f|
# head-only without --HEAD is an error
if !Homebrew.args.HEAD? && f.stable.nil? && f.devel.nil?
raise <<~EOS

View File

@ -15,6 +15,7 @@ module Homebrew
List installed formulae that are not dependencies of another installed formula.
EOS
switch :debug
max_named 0
end
end
@ -22,16 +23,8 @@ module Homebrew
leaves_args.parse
installed = Formula.installed.sort
deps_of_installed = installed.flat_map do |f|
f.runtime_dependencies.map do |dep|
dep.to_formula.full_name
rescue FormulaUnavailableError
dep.name
end
end
leaves = installed.map(&:full_name) - deps_of_installed
deps_of_installed = installed.flat_map(&:runtime_formula_dependencies)
leaves = installed.map(&:full_name) - deps_of_installed.map(&:full_name)
leaves.each(&method(:puts))
end
end

View File

@ -48,7 +48,10 @@ module Homebrew
else
keg.name
end
puts "To relink: brew unlink #{keg.name} && brew link #{name_and_flag}"
puts <<~EOS
To relink:
brew unlink #{keg.name} && brew link #{name_and_flag}
EOS
next
end

View File

@ -55,14 +55,14 @@ module Homebrew
# Unbrewed uses the PREFIX, which will exist
# Things below use the CELLAR, which doesn't until the first formula is installed.
unless HOMEBREW_CELLAR.exist?
raise NoSuchKegError, ARGV.named.first unless ARGV.named.empty?
raise NoSuchKegError, Hombrew.args.named.first if Homebrew.args.named.present?
return
end
if args.pinned? || args.versions?
filtered_list
elsif ARGV.named.empty?
elsif Homebrew.args.named.blank?
if args.full_name?
full_names = Formula.installed.map(&:full_name).sort(&tap_and_name_comparison)
return if full_names.empty?
@ -123,10 +123,10 @@ module Homebrew
end
def filtered_list
names = if ARGV.named.empty?
names = if Homebrew.args.named.blank?
Formula.racks
else
racks = ARGV.named.map { |n| Formulary.to_rack(n) }
racks = Homebrew.args.named.map { |n| Formulary.to_rack(n) }
racks.select do |rack|
Homebrew.failed = true unless rack.exist?
rack.exist?

View File

@ -22,6 +22,7 @@ module Homebrew
description: "Print only one line per commit."
flag "-1", "--max-count",
description: "Print only one or a specified number of commits."
max_named 1
end
end

View File

@ -25,7 +25,7 @@ module Homebrew
def migrate
migrate_args.parse
raise FormulaUnspecifiedError if ARGV.named.empty?
raise FormulaUnspecifiedError if Homebrew.args.named.blank?
ARGV.resolved_formulae.each do |f|
if f.oldname

View File

@ -27,9 +27,10 @@ module Homebrew
def missing
missing_args.parse
return unless HOMEBREW_CELLAR.exist?
ff = if ARGV.named.empty?
ff = if Homebrew.args.named.blank?
Formula.installed.sort
else
ARGV.resolved_formulae.sort

View File

@ -35,7 +35,7 @@ module Homebrew
else
raise FormulaUnspecifiedError if args.remaining.empty?
puts_options ARGV.formulae
puts_options Homebrew.args.formulae
end
end

View File

@ -10,7 +10,7 @@ module Homebrew
def outdated_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`outdated` [<options>]
`outdated` [<options>] [<formula>]
List installed formulae that have an updated version available. By default, version
information is displayed in interactive shells, and suppressed otherwise.
@ -41,7 +41,7 @@ module Homebrew
ARGV.resolved_formulae
end
if args.json
raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
outdated = print_outdated_json(formulae)
else

View File

@ -23,6 +23,8 @@ module Homebrew
def postinstall
postinstall_args.parse
raise KegUnspecifiedError if args.remaining.empty?
ARGV.resolved_formulae.each do |f|
ohai "Postinstalling #{f}"
fi = FormulaInstaller.new(f)

View File

@ -14,7 +14,7 @@ module Homebrew
Import all formulae from the specified <tap>, or from all installed taps if none is provided.
This can be useful for debugging issues across all formulae when making
significant changes to `formula.rb`, testing the performance of loading
all formulae or to determine if any current formulae have Ruby issues.
all formulae or checking if any current formulae have Ruby issues.
EOS
switch "--aliases",
description: "Verify any alias symlinks in each tap."

View File

@ -47,6 +47,8 @@ module Homebrew
def reinstall
reinstall_args.parse
raise FormulaUnspecifiedError if args.remaining.empty?
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
Install.perform_preinstall_checks

View File

@ -22,11 +22,13 @@ module Homebrew
description: "Use the standard `PATH` instead of superenv's when `std` is passed."
switch :verbose
switch :debug
max_named 0
end
end
def sh
sh_args.parse
ENV.activate_extensions!
if superenv?

View File

@ -38,14 +38,14 @@ module Homebrew
def style
style_args.parse
target = if ARGV.named.empty?
target = if Homebrew.args.named.blank?
nil
elsif ARGV.named.any? { |file| File.exist? file }
ARGV.named
elsif ARGV.named.any? { |tap| tap.count("/") == 1 }
ARGV.named.map { |tap| Tap.fetch(tap).path }
elsif Homebrew.args.named.any? { |file| File.exist? file }
Homebrew.args.named
elsif Homebrew.args.named.any? { |tap| tap.count("/") == 1 }
Homebrew.args.named.map { |tap| Tap.fetch(tap).path }
else
ARGV.formulae.map(&:path)
Homebrew.args.formulae.map(&:path)
end
only_cops = args.only_cops

View File

@ -14,46 +14,33 @@ module Homebrew
Symlink all of the specified <version> of <formula>'s installation into Homebrew's prefix.
EOS
switch_option :verbose
switch_option :debug
switch :verbose
switch :debug
max_named 2
end
end
def switch
switch_args.parse
raise FormulaUnspecifiedError if args.remaining.empty?
name = args.remaining.first
usage = "Usage: brew switch <formula> <version>"
unless name
onoe usage
exit 1
end
rack = Formulary.to_rack(name)
unless rack.directory?
onoe "#{name} not found in the Cellar."
exit 2
end
odie "#{name} not found in the Cellar." unless rack.directory?
versions = rack.subdirs
.map { |d| Keg.new(d).version }
.sort
.join(", ")
version = args.remaining.second
raise UsageError, "Specify one of #{name}'s installed versions: #{versions}" unless version
if !version || args.remaining.length > 2
onoe usage
puts "#{name} installed versions: #{versions}"
exit 1
end
unless (rack/version).directory?
onoe "#{name} does not have a version \"#{version}\" in the Cellar."
puts "#{name} installed versions: #{versions}"
exit 3
end
odie <<~EOS unless (rack/version).directory?
#{name} does not have a version \"#{version}\" in the Cellar.
#{name}'s installed versions: #{versions}
EOS
# Unlink all existing versions
rack.subdirs.each do |v|

View File

@ -30,13 +30,13 @@ module Homebrew
if args.installed?
taps = Tap
else
taps = ARGV.named.sort.map do |name|
taps = Homebrew.args.named.sort.map do |name|
Tap.fetch(name)
end
end
if args.json
raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
print_tap_json(taps.sort_by(&:to_s))
else

View File

@ -38,6 +38,7 @@ module Homebrew
switch "-q", "--quieter",
description: "Suppress any warnings."
switch :debug
max_named 2
end
end

View File

@ -79,7 +79,7 @@ module Homebrew
if rack.directory?
versions = rack.subdirs.map(&:basename)
puts "#{keg.name} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed."
puts "Remove all versions with `brew uninstall --force #{keg.name}`."
puts "Run `brew uninstall --force #{keg.name}` to remove all versions."
end
end
end
@ -87,7 +87,7 @@ module Homebrew
end
rescue MultipleVersionsInstalledError => e
ofail e
puts "Use `brew uninstall --force #{e.name}` to remove all versions."
puts "Run `brew uninstall --force #{e.name}` to remove all versions."
ensure
# If we delete Cellar/newname, then Cellar/oldname symlink
# can become broken and we have to remove it.

View File

@ -32,7 +32,7 @@ module Homebrew
def unpack
unpack_args.parse
formulae = ARGV.formulae
formulae = Homebrew.args.formulae
raise FormulaUnspecifiedError if formulae.empty?
if dir = args.destdir

View File

@ -19,11 +19,11 @@ module Homebrew
def untap
untap_args.parse
raise "Usage is `brew untap <tap-name>`" if args.remaining.empty?
raise UsageError, "This command requires a tap argument from `brew tap`'s list" if args.remaining.empty?
ARGV.named.each do |tapname|
tap = Tap.fetch(tapname)
raise "untapping #{tap} is not allowed" if tap.core_tap?
odie "Untapping #{tap} is not allowed" if tap.core_tap?
tap.uninstall
end

View File

@ -306,7 +306,7 @@ homebrew-update() {
*)
odie <<EOS
This command updates brew itself, and does not take formula names.
Use 'brew upgrade $@' instead.
Use \`brew upgrade $@\` instead.
EOS
;;
esac
@ -521,7 +521,7 @@ EOS
if [[ "$UPSTREAM_SHA_HTTP_CODE" = "404" ]]
then
TAP="${DIR#$HOMEBREW_LIBRARY/Taps/}"
echo "$TAP does not exist! Run 'brew untap $TAP'" >>"$update_failed_file"
echo "$TAP does not exist! Run \`brew untap $TAP\` to remove it." >>"$update_failed_file"
else
echo "Fetching $DIR failed!" >>"$update_failed_file"
fi

View File

@ -61,7 +61,7 @@ module Homebrew
Install.perform_preinstall_checks
if ARGV.named.empty?
if Homebrew.args.named.blank?
outdated = Formula.installed.select do |f|
f.outdated?(fetch_head: args.fetch_HEAD?)
end
@ -170,7 +170,7 @@ module Homebrew
fi = FormulaInstaller.new(f)
fi.options = options
fi.build_bottle = args.build_bottle?
fi.installed_on_request = !ARGV.named.empty?
fi.installed_on_request = Homebrew.args.named.present?
fi.link_keg ||= keg_was_linked if keg_had_linked_opt
if tab
fi.build_bottle ||= tab.built_bottle?
@ -239,9 +239,9 @@ module Homebrew
if pinned_dependents.present?
plural = "dependent".pluralize(pinned_dependents.count)
ohai "Not upgrading #{pinned_dependents.count} pinned #{plural}:"
puts pinned_dependents.map do |f|
puts(pinned_dependents.map do |f|
"#{f.full_specified_name} #{f.pkg_version}"
end.join(", ")
end.join(", "))
end
# Print the upgradable dependents.
@ -292,9 +292,9 @@ module Homebrew
count = pinned_broken_dependents.count
plural = "dependent".pluralize(pinned_broken_dependents.count)
onoe "Not reinstalling #{count} broken and outdated, but pinned #{plural}:"
$stderr.puts pinned_broken_dependents.map do |f|
$stderr.puts(pinned_broken_dependents.map do |f|
"#{f.full_specified_name} #{f.pkg_version}"
end.join(", ")
end.join(", "))
end
# Print the broken dependents.

View File

@ -50,12 +50,12 @@ module Homebrew
used_formulae_missing = false
used_formulae = begin
ARGV.formulae
Homebrew.args.formulae
rescue FormulaUnavailableError => e
opoo e
used_formulae_missing = true
# If the formula doesn't exist: fake the needed formula object name.
ARGV.named.map { |name| OpenStruct.new name: name, full_name: name }
Homebrew.args.named.map { |name| OpenStruct.new name: name, full_name: name }
end
use_runtime_dependents = args.installed? &&

View File

@ -2,3 +2,4 @@
require "compat/cask/dsl/version"
require "compat/requirements/macos_requirement"
require "compat/formula"

View File

@ -0,0 +1,13 @@
# frozen_string_literal: true
class Formula
module Compat
def installed?
# odeprecated "Formula#installed?",
# "Formula#latest_version_installed? (or Formula#any_version_installed? )"
latest_version_installed?
end
end
prepend Compat
end

View File

@ -98,19 +98,21 @@ module Homebrew
formula.send("recursive_#{type}") do |dependent, dep|
if dep.recommended?
klass.prune if ignores.include?("recommended?") || dependent.build.without?(dep)
elsif dep.optional?
klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
elsif dep.test?
if includes.include?("test?")
Dependency.keep_but_prune_recursive_deps if type == :dependencies
elsif dep.build?
klass.prune unless includes.include?("build?")
else
klass.prune
end
elsif dep.optional?
klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
elsif dep.build?
klass.prune unless includes.include?("build?")
end
# If a tap isn't installed, we can't find the dependencies of one
# If a tap isn't installed, we can't find the dependencies of one of
# its formulae, and an exception will be thrown if we try.
if type == :dependencies &&
dep.is_a?(TapDependency) &&

View File

@ -39,7 +39,9 @@ class Dependency
formula
end
delegate installed?: :to_formula
def installed?
to_formula.latest_version_installed?
end
def satisfied?(inherited_options)
installed? && missing_options(inherited_options).empty?

View File

@ -57,7 +57,8 @@ module Homebrew
switch :verbose
switch :debug
conflicts "--only", "--except"
conflicts "--only-cops", "--except-cops"
conflicts "--only-cops", "--except-cops", "--strict"
conflicts "--only-cops", "--except-cops", "--only"
end
end
@ -78,7 +79,7 @@ module Homebrew
ENV.activate_extensions!
ENV.setup_build_environment
if ARGV.named.empty?
if Homebrew.args.named.blank?
ff = Formula
files = Tap.map(&:formula_dir)
else
@ -88,13 +89,6 @@ module Homebrew
only_cops = args.only_cops
except_cops = args.except_cops
if only_cops && except_cops
odie "--only-cops and --except-cops cannot be used simultaneously!"
elsif (only_cops || except_cops) && (strict || args.only)
odie "--only-cops/--except-cops and --strict/--only cannot be used simultaneously!"
end
options = { fix: args.fix? }
if only_cops
@ -995,7 +989,6 @@ module Homebrew
def audit
only_audits = @only
except_audits = @except
odie "--only and --except cannot be used simultaneously!" if only_audits && except_audits
methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name|
name = audit_method_name.gsub(/^audit_/, "")

View File

@ -86,6 +86,7 @@ module Homebrew
bottle_args.parse
return merge if args.merge?
raise KegUnspecifiedError if args.remaining.empty?
ensure_relocation_formulae_installed! unless args.skip_relocation?
ARGV.resolved_formulae.each do |f|
@ -95,7 +96,7 @@ module Homebrew
def ensure_relocation_formulae_installed!
Keg.relocation_formulae.each do |f|
next if Formula[f].installed?
next if Formula[f].latest_version_installed?
ohai "Installing #{f}..."
safe_system HOMEBREW_BREW_FILE, "install", f
@ -172,7 +173,7 @@ module Homebrew
end
if text_matches.size > MAXIMUM_STRING_MATCHES
puts "Only the first #{MAXIMUM_STRING_MATCHES} matches were output"
puts "Only the first #{MAXIMUM_STRING_MATCHES} matches were output."
end
end
@ -205,7 +206,7 @@ module Homebrew
end
def bottle_formula(f)
return ofail "Formula not installed or up-to-date: #{f.full_name}" unless f.installed?
return ofail "Formula not installed or up-to-date: #{f.full_name}" unless f.latest_version_installed?
unless tap = f.tap
return ofail "Formula not from core or any installed taps: #{f.full_name}" unless args.force_core_tap?
@ -219,7 +220,7 @@ module Homebrew
return
end
return ofail "Formula not installed with '--build-bottle': #{f.full_name}" unless Utils::Bottles.built_as? f
return ofail "Formula was not installed with --build-bottle: #{f.full_name}" unless Utils::Bottles.built_as? f
return ofail "Formula has no stable version: #{f.full_name}" unless f.stable
@ -426,8 +427,9 @@ module Homebrew
def merge
write = args.write?
raise UsageError, "--merge requires a JSON file path argument" if Homebrew.args.named.blank?
bottles_hash = ARGV.named.reduce({}) do |hash, json_file|
bottles_hash = Homebrew.args.named.reduce({}) do |hash, json_file|
hash.deep_merge(JSON.parse(IO.read(json_file)))
end

View File

@ -65,6 +65,7 @@ module Homebrew
switch :debug
conflicts "--no-audit", "--strict"
conflicts "--url", "--tag"
max_named 1
end
end
@ -101,7 +102,7 @@ module Homebrew
end
end
end
[formula.tap.full_name, "origin/master", "-"]
[formula.tap&.full_name, "origin/master", "-"]
end
def bump_formula_pr
@ -114,7 +115,7 @@ module Homebrew
# Use the user's browser, too.
ENV["BROWSER"] = ENV["HOMEBREW_BROWSER"]
formula = ARGV.formulae.first
formula = Homebrew.args.formulae.first
if formula
tap_full_name, origin_branch, previous_branch = use_correct_linux_tap(formula)
@ -504,6 +505,6 @@ module Homebrew
formula.path.atomic_write(backup_file)
FileUtils.mv alias_rename.last, alias_rename.first if alias_rename.present?
odie "brew audit failed!"
odie "`brew audit` failed!"
end
end

View File

@ -22,6 +22,7 @@ module Homebrew
switch :quiet
switch :verbose
switch :debug
max_named 1
end
end
@ -32,10 +33,10 @@ module Homebrew
# user path, too.
ENV["PATH"] = ENV["HOMEBREW_PATH"]
raise FormulaUnspecifiedError if ARGV.formulae.empty?
raise "Multiple formulae given, only one is allowed." if ARGV.formulae.length > 1
formulae = Homebrew.args.formulae
raise FormulaUnspecifiedError if formulae.empty?
formula = ARGV.formulae.first
formula = formulae.first
current_revision = formula.revision
if current_revision.zero?

View File

@ -49,6 +49,7 @@ module Homebrew
switch :verbose
switch :debug
conflicts "--autotools", "--cmake", "--go", "--meson", "--perl", "--python", "--rust"
max_named 1
end
end
@ -121,7 +122,7 @@ module Homebrew
fc.generate!
puts "Please `brew audit --new-formula #{fc.name}` before submitting, thanks."
puts "Please run `brew audit --new-formula #{fc.name}` before submitting, thanks."
exec_editor fc.path
end

View File

@ -91,6 +91,7 @@ module Homebrew
description: "Extract the specified <version> of <formula> instead of the most recent."
switch :force
switch :debug
max_named 2
end
end
@ -98,7 +99,7 @@ module Homebrew
extract_args.parse
# Expect exactly two named arguments: formula and tap
raise UsageError if args.remaining.length != 2
raise UsageError, "This command requires formula and tap arguments" if args.remaining.length != 2
if args.remaining.first !~ HOMEBREW_TAP_FORMULA_REGEX
name = args.remaining.first.downcase
@ -125,24 +126,34 @@ module Homebrew
if args.version
ohai "Searching repository history"
version = args.version
rev = "HEAD"
version_segments = Gem::Version.new(version).segments if Gem::Version.correct?(version)
rev = nil
test_formula = nil
result = ""
loop do
rev, (path,) = Git.last_revision_commit_of_files(repo, pattern, before_commit: "#{rev}~1")
rev = rev.nil? ? "HEAD" : "#{rev}~1"
rev, (path,) = Git.last_revision_commit_of_files(repo, pattern, before_commit: rev)
odie "Could not find #{name}! The formula or version may not have existed." if rev.nil?
file = repo/path
result = Git.last_revision_of_file(repo, file, before_commit: rev)
if result.empty?
ohai "Skipping revision #{rev} - file is empty at this revision" if ARGV.debug?
odebug "Skipping revision #{rev} - file is empty at this revision"
next
end
test_formula = formula_at_revision(repo, name, file, rev)
break if test_formula.nil? || test_formula.version == version
ohai "Trying #{test_formula.version} from revision #{rev} against desired #{version}" if ARGV.debug?
if version_segments && Gem::Version.correct?(test_formula.version)
test_formula_version_segments = Gem::Version.new(test_formula.version).segments
if version_segments.length < test_formula_version_segments.length
odebug "Apply semantic versioning with #{test_formual_version_segments}"
break if version_segments == test_formula_version_segments.first(version_segments.length)
end
end
odebug "Trying #{test_formula.version} from revision #{rev} against desired #{version}"
end
odie "Could not find #{name}! The formula or version may not have existed." if test_formula.nil?
else
@ -181,7 +192,7 @@ module Homebrew
brew extract --force --version=#{version} #{name} #{destination_tap.name}
EOS
end
ohai "Overwriting existing formula at #{path}" if ARGV.debug?
odebug "Overwriting existing formula at #{path}"
path.delete
end
ohai "Writing formula for #{name} from revision #{rev} to #{path}"

View File

@ -21,7 +21,7 @@ module Homebrew
def formula
formula_args.parse
raise FormulaUnspecifiedError if ARGV.named.empty?
raise FormulaUnspecifiedError if Homebrew.args.named.blank?
ARGV.resolved_formulae.each { |f| puts f.path }
end

View File

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

View File

@ -5,7 +5,7 @@ require "erb"
require "ostruct"
require "cli/parser"
# Require all commands
Dir.glob("#{HOMEBREW_LIBRARY_PATH}/{dev-,}cmd/*.rb").each { |cmd| require cmd }
Dir.glob("#{HOMEBREW_LIBRARY_PATH}/{dev-,}cmd/*.rb").sort.each { |cmd| require cmd }
module Homebrew
module_function
@ -28,14 +28,13 @@ module Homebrew
"comparison without factoring in the date)."
switch "--link",
description: "This is now done automatically by `brew update`."
max_named 0
end
end
def man
man_args.parse
raise UsageError unless ARGV.named.empty?
odie "`brew man --link` is now done automatically by `brew update`." if args.link?
regenerate_man_pages

View File

@ -21,13 +21,13 @@ module Homebrew
def mirror
mirror_args.parse
odie "This command requires at least one formula argument!" if ARGV.named.empty?
raise FormulaUnspecifiedError if args.remaining.empty?
bintray_user = ENV["HOMEBREW_BINTRAY_USER"]
bintray_key = ENV["HOMEBREW_BINTRAY_KEY"]
raise "Missing HOMEBREW_BINTRAY_USER or HOMEBREW_BINTRAY_KEY variables!" if !bintray_user || !bintray_key
ARGV.formulae.each do |f|
Homebrew.args.formulae.each do |f|
bintray_package = Utils::Bottles::Bintray.package f.name
bintray_repo_url = "https://api.bintray.com/packages/homebrew/mirror"
package_url = "#{bintray_repo_url}/#{bintray_package}"

View File

@ -70,7 +70,9 @@ module Homebrew
pull_args.parse
odie "This command requires at least one argument containing a URL or pull request number" if ARGV.named.empty?
if ARGV.named.empty?
raise UsageError, "This command requires at least one argument containing a URL or pull request number"
end
# Passthrough Git environment variables for e.g. git am
ENV["GIT_COMMITTER_NAME"] = ENV["HOMEBREW_GIT_NAME"] if ENV["HOMEBREW_GIT_NAME"]
@ -107,7 +109,7 @@ module Homebrew
end
_, testing_job = *testing_match
url = "https://github.com/Homebrew/homebrew-#{tap.repo}/compare/master...BrewTestBot:testing-#{testing_job}"
odie "Testing URLs require `--bottle`!" unless args.bottle?
odie "--bottle is required for testing job URLs!" unless args.bottle?
elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX)
_, user, repo, issue = *api_match
url = "https://github.com/#{user}/#{repo}/pull/#{issue}"
@ -277,7 +279,7 @@ module Homebrew
elsif patch_changes[:formulae].length > 1
odie "Can only bump one changed formula; bumped #{patch_changes[:formulae]}"
elsif !patch_changes[:others].empty?
odie "Can not bump if non-formula files are changed"
odie "Cannot bump if non-formula files are changed"
end
end

View File

@ -16,6 +16,7 @@ module Homebrew
EOS
switch "--markdown",
description: "Print as a Markdown list."
max_named 2
end
end

View File

@ -15,13 +15,14 @@ module Homebrew
EOS
switch :verbose
switch :debug
max_named 1
end
end
def tap_new
tap_new_args.parse
raise "A tap argument is required" if ARGV.named.empty?
raise UsageError, "This command requires a tap argument" if ARGV.named.empty?
tap = Tap.fetch(ARGV.named.first)
titleized_user = tap.user.dup

View File

@ -40,7 +40,7 @@ module Homebrew
ARGV.resolved_formulae.each do |f|
# Cannot test uninstalled formulae
unless f.installed?
unless f.latest_version_installed?
ofail "Testing requires the latest version of #{f.full_name}"
next
end

View File

@ -29,6 +29,7 @@ module Homebrew
description: "Randomise tests with the specified <value> instead of a random seed."
switch :verbose
switch :debug
max_named 0
end
end

View File

@ -23,6 +23,7 @@ module Homebrew
description: "Use the commit at the specified <date> as the start commit."
switch :verbose
switch :debug
max_named 0
end
end
@ -88,7 +89,7 @@ module Homebrew
chdir "update-test" do
curdir = Pathname.new(Dir.pwd)
oh1 "Setup test environment..."
oh1 "Preparing test environment..."
# copy Homebrew installation
safe_system "git", "clone", "#{HOMEBREW_REPOSITORY}/.git", ".",
"--branch", "master", "--single-branch"

View File

@ -14,6 +14,7 @@ module Homebrew
Install and commit Homebrew's vendored gems.
EOS
switch :debug
max_named 0
end
end
@ -33,7 +34,7 @@ module Homebrew
ohai "git add vendor/bundle"
system "git", "add", "vendor/bundle"
if Formula["gpg"].installed?
if Formula["gpg"].optlinked?
ENV["PATH"] = PATH.new(ENV["PATH"])
.prepend(Formula["gpg"].opt_bin)
end

View File

@ -1122,7 +1122,7 @@ class DownloadStrategyDetector
when :post then CurlPostDownloadStrategy
when :fossil then FossilDownloadStrategy
else
raise "Unknown download strategy #{symbol} was requested."
raise TypeError, "Unknown download strategy #{symbol} was requested."
end
end
end

View File

@ -14,6 +14,7 @@ class LinkageChecker
libpthread.so.0
libresolv.so.2
librt.so.1
libthread_db.so.1
libutil.so.1
libgcc_s.so.1

View File

@ -6,7 +6,7 @@ class OsxfuseRequirement < Requirement
download "https://github.com/libfuse/libfuse"
satisfy(build_env: false) do
next true if libfuse_formula_exists? && Formula["libfuse"].installed?
next true if libfuse_formula_exists? && Formula["libfuse"].latest_version_installed?
includedirs = %w[
/usr/include

View File

@ -3,30 +3,8 @@
class SoftwareSpec
undef uses_from_macos
def uses_from_macos(deps, **args)
def uses_from_macos(deps)
@uses_from_macos_elements ||= []
if deps.is_a?(Hash)
args = deps
deps = Hash[*args.shift]
end
if add_mac_dependency?(args)
depends_on(deps)
else
@uses_from_macos_elements << deps
end
end
private
def add_mac_dependency?(args)
args.each { |key, version| args[key] = OS::Mac::Version.from_symbol(version) }
return false if args[:after] && OS::Mac.version >= args[:after]
return false if args[:before] && OS::Mac.version < args[:before]
args.present?
@uses_from_macos_elements << deps
end
end

View File

@ -41,10 +41,6 @@ class SystemConfig
@clt ||= MacOS::CLT.version if MacOS::CLT.installed?
end
def clt_headers
@clt_headers ||= MacOS::CLT.headers_version if MacOS::CLT.headers_installed?
end
def xquartz
@xquartz ||= "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" if MacOS::XQuartz.installed?
end
@ -54,7 +50,6 @@ class SystemConfig
f.puts "macOS: #{MacOS.full_version}-#{kernel}"
f.puts "CLT: #{clt || "N/A"}"
f.puts "Xcode: #{xcode || "N/A"}"
f.puts "CLT headers: #{clt_headers}" if MacOS::CLT.separate_header_package? && clt_headers
f.puts "XQuartz: #{xquartz}" if xquartz
end
end

View File

@ -463,7 +463,7 @@ class Formula
# This is actually just a check for if the {#installed_prefix} directory
# exists and is not empty.
# @private
def installed?
def latest_version_installed?
(dir = installed_prefix).directory? && !dir.children.empty?
end
@ -1211,7 +1211,7 @@ class Formula
end
def new_formula_available?
installed_alias_target_changed? && !latest_formula.installed?
installed_alias_target_changed? && !latest_formula.latest_version_installed?
end
def current_installed_alias_target
@ -1546,8 +1546,13 @@ class Formula
Dependency.new full_name
end.compact
end
deps ||= declared_runtime_dependencies unless undeclared
deps ||= (declared_runtime_dependencies | undeclared_runtime_dependencies)
begin
deps ||= declared_runtime_dependencies unless undeclared
deps ||= (declared_runtime_dependencies | undeclared_runtime_dependencies)
rescue FormulaUnavailableError
onoe "could not get runtime dependencies from #{path}!"
deps ||= []
end
deps
end
@ -1932,7 +1937,7 @@ class Formula
# @private
def eligible_kegs_for_cleanup(quiet: false)
eligible_for_cleanup = []
if installed?
if latest_version_installed?
eligible_kegs = if head? && (head_prefix = latest_head_prefix)
installed_kegs - [Keg.new(head_prefix)]
else
@ -2370,8 +2375,8 @@ class Formula
specs.each { |spec| spec.depends_on(dep) }
end
def uses_from_macos(dep, **args)
specs.each { |spec| spec.uses_from_macos(dep, args) }
def uses_from_macos(dep)
specs.each { |spec| spec.uses_from_macos(dep) }
end
# @!attribute [w] option

View File

@ -100,7 +100,7 @@ module FormulaCellarChecks
def check_generic_executables(bin)
return unless bin.directory?
generic_names = %w[run service start stop]
generic_names = %w[service start stop]
generics = bin.children.select { |g| generic_names.include? g.basename.to_s }
return if generics.empty?

View File

@ -343,7 +343,7 @@ class FormulaInstaller
build_bottle_postinstall if build_bottle?
opoo "Nothing was installed to #{formula.prefix}" unless formula.installed?
opoo "Nothing was installed to #{formula.prefix}" unless formula.latest_version_installed?
end_time = Time.now
Homebrew.messages.formula_installed(formula, end_time - start_time)
end
@ -598,6 +598,10 @@ class FormulaInstaller
oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}"
fi.install
fi.finish
rescue FormulaInstallationAlreadyAttemptedError
# We already attempted to install f as part of the dependency tree of
# another formula. In that case, don't generate an error, just move on.
nil
rescue Exception # rubocop:disable Lint/RescueException
ignore_interrupts do
tmp_keg.rename(installed_keg) if tmp_keg && !installed_keg.directory?
@ -910,13 +914,7 @@ class FormulaInstaller
--
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
#{formula.path}
].concat(ARGV.options_only) - ["--HEAD", "--devel"]
if formula.head?
args << "--HEAD"
elsif formula.devel?
args << "--devel"
end
]
Utils.safe_fork do
if Sandbox.formula?(formula)

View File

@ -44,7 +44,7 @@ class FormulaVersions
rescue *IGNORED_EXCEPTIONS => e
# We rescue these so that we can skip bad versions and
# continue walking the history
ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
odebug "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
rescue FormulaUnavailableError
nil
ensure

View File

@ -153,7 +153,8 @@ module Language
def virtualenv_install_with_resources(options = {})
python = options[:using]
if python.nil?
wanted = %w[python python@2 python2 python3 python@3 pypy pypy3].select { |py| needs_python?(py) }
pythons = %w[python python@2 python2 python3 python@3 python@3.8 pypy pypy3]
wanted = pythons.select { |py| needs_python?(py) }
raise FormulaAmbiguousPythonError, self if wanted.size > 1
python = wanted.first || "python2.7"

View File

@ -9,7 +9,7 @@
#
# When done, regenerate the man page and its HTML version by running `brew man`.
%>
brew(1) -- The missing package manager for macOS
brew(1) -- The Missing Package Manager for macOS
================================================
## SYNOPSIS

View File

@ -5,7 +5,7 @@ class Keg
return if file.dylib_id == id
@require_relocation = true
puts "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}" if ARGV.debug?
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}" if ARGV.debug?
MachO::Tools.change_dylib_id(file, id, strict: false)
rescue MachO::MachOError
onoe <<~EOS
@ -20,7 +20,7 @@ class Keg
return if old == new
@require_relocation = true
puts "Changing install name in #{file}\n from #{old}\n to #{new}" if ARGV.debug?
odebug "Changing install name in #{file}\n from #{old}\n to #{new}" if ARGV.debug?
MachO::Tools.change_install_name(file, old, new, strict: false)
rescue MachO::MachOError
onoe <<~EOS

View File

@ -16,13 +16,13 @@ module OS
when "10.11" then "8.2.1"
when "10.12" then "9.2"
when "10.13" then "10.1"
when "10.14" then "10.2.1"
when "10.15" then "11.2.1"
when "10.14" then "11.3"
when "10.15" then "11.3"
else
raise "macOS '#{MacOS.version}' is invalid" unless OS::Mac.prerelease?
# Default to newest known version of Xcode for unreleased macOS versions.
"11.2.1"
"11.3"
end
end
@ -176,8 +176,8 @@ module OS
when 90 then "9.2"
when 91 then "9.4"
when 100 then "10.2.1"
when 110 then "11.2.1"
else "11.2.1"
when 110 then "11.3"
else "11.3"
end
end
@ -193,9 +193,6 @@ module OS
EXECUTABLE_PKG_ID = "com.apple.pkg.CLTools_Executables"
MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base" # obsolete
PKG_PATH = "/Library/Developer/CommandLineTools"
HEADER_PKG_PATH =
"/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_:macos_version.pkg"
HEADER_PKG_ID = "com.apple.pkg.macOS_SDK_headers_for_macOS_10.14"
# Returns true even if outdated tools are installed
def installed?
@ -210,14 +207,6 @@ module OS
version >= "8"
end
def headers_installed?
if !separate_header_package?
installed?
else
headers_version == version
end
end
def sdk(v = nil)
@locator ||= CLTSDKLocator.new
@ -236,18 +225,18 @@ module OS
EOS
else
<<~EOS
Update them from Software Update in the App Store
Update them from Software Update in the App Store or
#{Formatter.url("https://developer.apple.com/download/more/")}.
EOS
end
end
def latest_version
def latest_clang_version
# As of Xcode 8 CLT releases are no longer in sync with Xcode releases
# on the older supported platform for that Xcode release, i.e there's no
# CLT package for 10.11 that contains the Clang version from Xcode 8.
case MacOS.version
when "10.15" then "1100.0.33.12"
when "10.15" then "1100.0.33.16"
when "10.14" then "1001.0.46.4"
when "10.13" then "1000.10.44.2"
when "10.12" then "900.0.39.2"
@ -277,7 +266,7 @@ module OS
clang_version = detect_clang_version
return false unless clang_version
::Version.new(clang_version) < latest_version
::Version.new(clang_version) < latest_clang_version
end
def detect_clang_version
@ -291,6 +280,10 @@ module OS
version_output[/clang-(\d+\.\d+\.\d+(\.\d+)?)/, 1]
end
def detect_version_from_clang_version
detect_clang_version&.sub(/^(\d+)00\./, "\\1.")
end
# Version string (a pretty long one) of the CLT package.
# Note, that different ways to install the CLTs lead to different
# version numbers.
@ -302,19 +295,6 @@ module OS
end
end
# Version string of the header package, which is a
# separate package as of macOS 10.14.
def headers_version
if !separate_header_package?
version
else
@header_version ||= MacOS.pkgutil_info(HEADER_PKG_ID)[/version: (.+)$/, 1]
return ::Version::NULL unless @header_version
::Version.new(@header_version)
end
end
def detect_version
version = nil
[EXECUTABLE_PKG_ID, MAVERICKS_NEW_PKG_ID].each do |id|
@ -324,7 +304,7 @@ module OS
return version if version
end
detect_clang_version
detect_version_from_clang_version
end
end
end

View File

@ -6,15 +6,24 @@ require "global"
require "debrew"
require "fcntl"
require "socket"
require "cli/parser"
def postinstall_args
Homebrew::CLI::Parser.new do
switch :force
switch :verbose
switch :debug
end
end
begin
postinstall_args.parse
error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
trap("INT", old_trap)
formula = ARGV.resolved_formulae.first
formula.extend(Debrew::Formula) if ARGV.debug?
formula = Homebrew.args.resolved_formulae.first
formula.run_post_install
rescue Exception => e # rubocop:disable Lint/RescueException
error_pipe.puts e.to_json

View File

@ -132,7 +132,7 @@ class Resource
end
rescue ChecksumMissingError
opoo "Cannot verify integrity of #{fn.basename}"
puts "A checksum was not provided for this resource"
puts "A checksum was not provided for this resource."
puts "For your reference the SHA-256 is: #{fn.sha256}"
end

View File

@ -171,10 +171,8 @@ class SoftwareSpec
add_dep_option(dep) if dep
end
def uses_from_macos(deps, **_args)
deps = Hash[*deps.shift] if deps.is_a?(Hash)
depends_on(deps)
def uses_from_macos(spec)
depends_on(spec)
end
def deps

View File

@ -85,50 +85,50 @@ describe Cask::DSL::Version, :cask do
describe "string manipulation helpers" do
describe "#major" do
include_examples "version expectations hash", :major,
"1" => "1",
"1.2" => "1",
"1.2.3" => "1",
"1.2.3_4-5" => "1"
"1" => "1",
"1.2" => "1",
"1.2.3" => "1",
"1.2.3-4,5:6" => "1"
end
describe "#minor" do
include_examples "version expectations hash", :minor,
"1" => "",
"1.2" => "2",
"1.2.3" => "2",
"1.2.3_4-5" => "2"
"1" => "",
"1.2" => "2",
"1.2.3" => "2",
"1.2.3-4,5:6" => "2"
end
describe "#patch" do
include_examples "version expectations hash", :patch,
"1" => "",
"1.2" => "",
"1.2.3" => "3",
"1.2.3_4-5" => "3"
"1" => "",
"1.2" => "",
"1.2.3" => "3",
"1.2.3-4,5:6" => "3-4"
end
describe "#major_minor" do
include_examples "version expectations hash", :major_minor,
"1" => "1",
"1.2" => "1.2",
"1.2.3" => "1.2",
"1.2.3_4-5" => "1.2"
"1" => "1",
"1.2" => "1.2",
"1.2.3" => "1.2",
"1.2.3-4,5:6" => "1.2"
end
describe "#major_minor_patch" do
include_examples "version expectations hash", :major_minor_patch,
"1" => "1",
"1.2" => "1.2",
"1.2.3" => "1.2.3",
"1.2.3_4-5" => "1.2.3"
"1" => "1",
"1.2" => "1.2",
"1.2.3" => "1.2.3",
"1.2.3-4,5:6" => "1.2.3-4"
end
describe "#minor_patch" do
include_examples "version expectations hash", :minor_patch,
"1" => "",
"1.2" => "2",
"1.2.3" => "2.3",
"1.2.3_4-5" => "2.3"
"1" => "",
"1.2" => "2",
"1.2.3" => "2.3",
"1.2.3-4,5:6" => "2.3-4"
end
describe "#before_comma" do

View File

@ -124,17 +124,17 @@ describe Homebrew::Cleanup do
Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
end
expect(f1).to be_installed
expect(f2).to be_installed
expect(f3).to be_installed
expect(f4).to be_installed
expect(f1).to be_latest_version_installed
expect(f2).to be_latest_version_installed
expect(f3).to be_latest_version_installed
expect(f4).to be_latest_version_installed
subject.cleanup_formula f3
expect(f1).not_to be_installed
expect(f2).not_to be_installed
expect(f3).to be_installed
expect(f4).to be_installed
expect(f1).not_to be_latest_version_installed
expect(f2).not_to be_latest_version_installed
expect(f3).to be_latest_version_installed
expect(f4).to be_latest_version_installed
end
describe "#cleanup_cask", :cask do

View File

@ -236,6 +236,21 @@ describe Homebrew::CLI::Parser do
expect(Homebrew.args.passthrough).to eq %w[--foo --bar=value -s]
end
it "#formulae raises an error when a Formula is unavailable" do
parser.parse(["mxcl"])
expect { Homebrew.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
end
it "#casks returns an empty array when there are no matching casks" do
parser.parse([])
expect(Homebrew.args.casks).to eq []
end
context "kegs" do
before do
keg = HOMEBREW_CELLAR + "mxcl/10.0"
@ -252,5 +267,15 @@ describe Homebrew::CLI::Parser do
expect(Homebrew.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"]
end
it "#named returns an empty array when there are no named arguments" do
parser.parse([])
expect(Homebrew.args.named).to be_empty
end
end
end

View File

@ -7,7 +7,7 @@ describe "Homebrew.extract_args" do
end
describe "brew extract", :integration_test do
it "retrieves the specified version of formula, defaulting to most recent" do
let!(:target) do
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
(path/"Formula").mkpath
target = Tap.from_path(path)
@ -23,12 +23,27 @@ describe "brew extract", :integration_test do
system "git", "add", "--all"
system "git", "commit", "-m", "testball 0.2"
end
{ name: target.name, path: path }
end
expect { brew "extract", "testball", target.name, "--version=0.1" }
it "retrieves the most recent version of formula" do
expect { brew "extract", "testball", target[:name] }
.to be_a_success
expect(target[:path]/"Formula/testball@0.2.rb").to exist
expect(Formulary.factory(target[:path]/"Formula/testball@0.2.rb").version).to be == "0.2"
end
expect(path/"Formula/testball@0.1.rb").to exist
it "retrieves the specified version of formula" do
expect { brew "extract", "testball", target[:name], "--version=0.1" }
.to be_a_success
expect(target[:path]/"Formula/testball@0.1.rb").to exist
expect(Formulary.factory(target[:path]/"Formula/testball@0.1.rb").version).to be == "0.1"
end
expect(Formulary.factory(path/"Formula/testball@0.1.rb").version).to be == "0.1"
it "retrieves the compatible version of formula" do
expect { brew "extract", "testball", target[:name], "--version=0", "--debug" }
.to be_a_success
expect(target[:path]/"Formula/testball@0.rb").to exist
expect(Formulary.factory(target[:path]/"Formula/testball@0.rb").version).to be == "0.2"
end
end

View File

@ -6,7 +6,8 @@ describe "Homebrew.test_args" do
it_behaves_like "parseable arguments"
end
describe "brew test", :integration_test do
# randomly segfaults on Linux with portable-ruby.
describe "brew test", :integration_test, :needs_macos do
it "tests a given Formula" do
install_test_formula "testball", <<~'RUBY'
test do

View File

@ -15,19 +15,19 @@ describe FormulaInstaller do
end
def temporarily_install_bottle(formula)
expect(formula).not_to be_installed
expect(formula).not_to be_latest_version_installed
expect(formula).to be_bottled
expect(formula).to pour_bottle
stub_formula_loader formula
stub_formula_loader formula("gcc") { url "gcc-1.0" }
stub_formula_loader formula("patchelf") { url "patchelf-1.0" }
allow(Formula["patchelf"]).to receive(:installed?).and_return(true)
allow(Formula["patchelf"]).to receive(:latest_version_installed?).and_return(true)
described_class.new(formula).install
keg = Keg.new(formula.prefix)
expect(formula).to be_installed
expect(formula).to be_latest_version_installed
begin
expect(Tab.for_keg(keg)).to be_poured_from_bottle
@ -41,7 +41,7 @@ describe FormulaInstaller do
end
expect(keg).not_to exist
expect(formula).not_to be_installed
expect(formula).not_to be_latest_version_installed
end
specify "basic bottle install" do
@ -73,13 +73,13 @@ describe FormulaInstaller do
# Testball doesn't have a bottle block, so use it to test this behavior
formula = Testball.new
expect(formula).not_to be_installed
expect(formula).not_to be_latest_version_installed
expect(formula).not_to be_bottled
expect {
described_class.new(formula).install
}.to raise_error(BuildToolsError)
expect(formula).not_to be_installed
expect(formula).not_to be_latest_version_installed
end
end

View File

@ -17,7 +17,7 @@ describe FormulaInstaller do
end
def temporary_install(formula)
expect(formula).not_to be_installed
expect(formula).not_to be_latest_version_installed
installer = described_class.new(formula)
@ -25,7 +25,7 @@ describe FormulaInstaller do
keg = Keg.new(formula.prefix)
expect(formula).to be_installed
expect(formula).to be_latest_version_installed
begin
Tab.clear_cache
@ -42,7 +42,7 @@ describe FormulaInstaller do
end
expect(keg).not_to exist
expect(formula).not_to be_installed
expect(formula).not_to be_latest_version_installed
end
specify "basic installation" do
@ -84,7 +84,7 @@ describe FormulaInstaller do
expect(formula).to have_disabled_bottle
temporary_install(formula) do |f|
expect(f).to be_installed
expect(f).to be_latest_version_installed
end
end

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