Deprecate/disable code for Homebrew 2.5.0.

Do the usual "disable deprecations" and "uncomment pending deprecations"
dance and delete/deprecate/disable relevant/related code.
This commit is contained in:
Mike McQuaid 2020-09-03 10:34:22 +01:00
parent 2b3d1e7a52
commit 2e5272d04c
42 changed files with 150 additions and 755 deletions

View File

@ -10,11 +10,11 @@ class BuildOptions
@options = options @options = options
end end
# True if a {Formula} is being built with a specific option # TODO: rename private_include? when include? is removed.
# (which isn't named `with-*` or `without-*`).
# @deprecated # @deprecated
def include?(name) def include?(name)
@args.include?("--#{name}") odeprecated "BuildOptions#include?"
private_include?("--#{name}")
end end
# True if a {Formula} is being built with a specific option. # True if a {Formula} is being built with a specific option.
@ -33,9 +33,9 @@ class BuildOptions
option_names.any? do |name| option_names.any? do |name|
if option_defined? "with-#{name}" if option_defined? "with-#{name}"
include? "with-#{name}" private_include? "with-#{name}"
elsif option_defined? "without-#{name}" elsif option_defined? "without-#{name}"
!include? "without-#{name}" !private_include? "without-#{name}"
else else
false false
end end
@ -50,7 +50,7 @@ class BuildOptions
# True if a {Formula} is being built as a bottle (i.e. binary package). # True if a {Formula} is being built as a bottle (i.e. binary package).
def bottle? def bottle?
include? "build-bottle" private_include? "build-bottle"
end end
# True if a {Formula} is being built with {Formula.head} instead of {Formula.stable}. # True if a {Formula} is being built with {Formula.head} instead of {Formula.stable}.
@ -61,32 +61,33 @@ class BuildOptions
# args << "--and-a-cold-beer" if build.with? "cold-beer" # args << "--and-a-cold-beer" if build.with? "cold-beer"
# end</pre> # end</pre>
def head? def head?
include? "HEAD" private_include? "HEAD"
end end
# True if a {Formula} is being built with {Formula.devel} instead of {Formula.stable}. # @private
# <pre>args << "--some-beta" if build.devel?</pre>
def devel? def devel?
include? "devel" odisabled "BuildOptions#devel?"
end end
# True if a {Formula} is being built with {Formula.stable} instead of {Formula.devel} # True if a {Formula} is being built with {Formula.stable} instead of {Formula.head}.
# or {Formula.head}. This is the default. # This is the default.
# <pre>args << "--some-beta" if build.devel?</pre> # <pre>args << "--some-beta" if build.head?</pre>
def stable? def stable?
!(head? || devel?) !head?
end end
# True if a {Formula} is being built universally. # True if a {Formula} is being built universally.
# e.g. on newer Intel Macs this means a combined x86_64/x86 binary/library. # e.g. on newer Intel Macs this means a combined x86_64/x86 binary/library.
# <pre>args << "--universal-binary" if build.universal?</pre> # <pre>args << "--universal-binary" if build.universal?</pre>
def universal? def universal?
include?("universal") && option_defined?("universal") odeprecated "BuildOptions#universal?"
private_include?("universal") && option_defined?("universal")
end end
# True if a {Formula} is being built in C++11 mode. # True if a {Formula} is being built in C++11 mode.
def cxx11? def cxx11?
include?("c++11") && option_defined?("c++11") odeprecated "BuildOptions#cxx11?"
private_include?("c++11") && option_defined?("c++11")
end end
# True if the build has any arguments or options specified. # True if the build has any arguments or options specified.
@ -106,6 +107,11 @@ class BuildOptions
private private
# TODO: rename to include? when include? is removed.
def private_include?(name)
@args.include?("--#{name}")
end
def option_defined?(name) def option_defined?(name)
@options.include? name @options.include? name
end end

View File

@ -227,10 +227,9 @@ module Cask
detect_external_command(*argv) || detect_external_command(*argv) ||
[args.remaining.empty? ? NullCommand : UnknownSubcommand.new(args.remaining.first), argv] [args.remaining.empty? ? NullCommand : UnknownSubcommand.new(args.remaining.first), argv]
# TODO: enable for next major/minor release if (replacement = DEPRECATED_COMMANDS[command])
# if (replacement = DEPRECATED_COMMANDS[command]) odeprecated "brew cask #{command.command_name}", replacement
# odeprecated "brew cask #{command.command_name}", replacement end
# end
if args.help? if args.help?
puts command.help puts command.help

View File

@ -57,66 +57,57 @@ module Homebrew
end end
def formulae def formulae
# TODO: enable for next major/minor release odeprecated "args.formulae", "args.named.to_formulae"
# odeprecated "args.formulae", "args.named.to_formulae"
named.to_formulae named.to_formulae
end end
def formulae_and_casks def formulae_and_casks
# TODO: enable for next major/minor release odeprecated "args.formulae_and_casks", "args.named.to_formulae_and_casks"
# odeprecated "args.formulae_and_casks", "args.named.to_formulae_and_casks"
named.to_formulae_and_casks named.to_formulae_and_casks
end end
def resolved_formulae def resolved_formulae
# TODO: enable for next major/minor release odeprecated "args.resolved_formulae", "args.named.to_resolved_formulae"
# odeprecated "args.resolved_formulae", "args.named.to_resolved_formulae"
named.to_resolved_formulae named.to_resolved_formulae
end end
def resolved_formulae_casks def resolved_formulae_casks
# TODO: enable for next major/minor release odeprecated "args.resolved_formulae_casks", "args.named.to_resolved_formulae_to_casks"
# odeprecated "args.resolved_formulae_casks", "args.named.to_resolved_formulae_to_casks"
named.to_resolved_formulae_to_casks named.to_resolved_formulae_to_casks
end end
def formulae_paths def formulae_paths
# TODO: enable for next major/minor release odeprecated "args.formulae_paths", "args.named.to_formulae_paths"
# odeprecated "args.formulae_paths", "args.named.to_formulae_paths"
named.to_formulae_paths named.to_formulae_paths
end end
def casks def casks
# TODO: enable for next major/minor release odeprecated "args.casks", "args.named.homebrew_tap_cask_names"
# odeprecated "args.casks", "args.named.homebrew_tap_cask_names"
named.homebrew_tap_cask_names named.homebrew_tap_cask_names
end end
def loaded_casks def loaded_casks
# TODO: enable for next major/minor release odeprecated "args.loaded_casks", "args.named.to_cask"
# odeprecated "args.loaded_casks", "args.named.to_cask"
named.to_casks named.to_casks
end end
def kegs def kegs
# TODO: enable for next major/minor release odeprecated "args.kegs", "args.named.to_kegs"
# odeprecated "args.kegs", "args.named.to_kegs"
named.to_kegs named.to_kegs
end end
def kegs_casks def kegs_casks
# TODO: enable for next major/minor release odeprecated "args.kegs", "args.named.to_kegs_to_casks"
# odeprecated "args.kegs", "args.named.to_kegs_to_casks"
named.to_kegs_to_casks named.to_kegs_to_casks
end end
def build_stable? def build_stable?
!(HEAD? || devel?) !HEAD?
end end
def build_from_source_formulae def build_from_source_formulae
if build_from_source? || build_bottle? if build_from_source? || build_bottle?
formulae.map(&:full_name) named.to_formulae.map(&:full_name)
else else
[] []
end end
@ -124,7 +115,7 @@ module Homebrew
def include_test_formulae def include_test_formulae
if include_test? if include_test?
formulae.map(&:full_name) named.to_formulae.map(&:full_name)
else else
[] []
end end
@ -171,8 +162,6 @@ module Homebrew
def spec(default = :stable) def spec(default = :stable)
if HEAD? if HEAD?
:head :head
elsif devel?
:devel
else else
default default
end end

View File

@ -410,8 +410,6 @@ module Homebrew
named_args = argv.reject { |arg| arg.start_with?("-") } + non_options named_args = argv.reject { |arg| arg.start_with?("-") } + non_options
spec = if argv.include?("--HEAD") spec = if argv.include?("--HEAD")
:head :head
elsif argv.include?("--devel")
:devel
else else
:stable :stable
end end

View File

@ -166,10 +166,6 @@ module Homebrew
specs << s specs << s
end end
if devel = f.devel
specs << "devel #{devel.version}"
end
specs << "HEAD" if f.head specs << "HEAD" if f.head
attrs = [] attrs = []
@ -229,7 +225,7 @@ module Homebrew
end end
end end
if !f.options.empty? || f.head || f.devel if !f.options.empty? || f.head
ohai "Options" ohai "Options"
Options.dump_for_formula f Options.dump_for_formula f
end end

View File

@ -54,8 +54,6 @@ module Homebrew
"macOS, even if it would not normally be used for installation." "macOS, even if it would not normally be used for installation."
switch "--include-test", switch "--include-test",
description: "Install testing dependencies required to run `brew test` <formula>." description: "Install testing dependencies required to run `brew test` <formula>."
switch "--devel",
description: "If <formula> defines it, install the development version."
switch "--HEAD", switch "--HEAD",
description: "If <formula> defines it, install the HEAD version, aka. master, trunk, unstable." description: "If <formula> defines it, install the HEAD version, aka. master, trunk, unstable."
switch "--fetch-HEAD", switch "--fetch-HEAD",
@ -133,31 +131,16 @@ module Homebrew
args.named.to_formulae.each do |f| args.named.to_formulae.each do |f|
# head-only without --HEAD is an error # head-only without --HEAD is an error
if !args.HEAD? && f.stable.nil? && f.devel.nil? if !args.HEAD? && f.stable.nil?
raise <<~EOS raise <<~EOS
#{f.full_name} is a head-only formula #{f.full_name} is a head-only formula
Install with `brew install --HEAD #{f.full_name}` Install with `brew install --HEAD #{f.full_name}`
EOS EOS
end end
# devel-only without --devel is an error
if !args.devel? && f.stable.nil? && f.head.nil?
raise <<~EOS
#{f.full_name} is a devel-only formula
Install with `brew install --devel #{f.full_name}`
EOS
end
if !(args.HEAD? || args.devel?) && f.stable.nil?
raise "#{f.full_name} has no stable download, please choose --devel or --HEAD"
end
# --HEAD, fail with no head defined # --HEAD, fail with no head defined
raise "No head is defined for #{f.full_name}" if args.HEAD? && f.head.nil? raise "No head is defined for #{f.full_name}" if args.HEAD? && f.head.nil?
# --devel, fail with no devel defined
raise "No devel block is defined for #{f.full_name}" if args.devel? && f.devel.nil?
installed_head_version = f.latest_head_version installed_head_version = f.latest_head_version
if installed_head_version && if installed_head_version &&
!f.head_version_outdated?(installed_head_version, fetch_head: args.fetch_HEAD?) !f.head_version_outdated?(installed_head_version, fetch_head: args.fetch_HEAD?)

View File

@ -44,10 +44,9 @@ module Homebrew
def outdated def outdated
args = outdated_args.parse args = outdated_args.parse
case json_version(args.json) case (j = json_version(args.json))
when :v1, :default when :v1, :default
# TODO: enable for next major/minor release odeprecated "brew outdated --json#{j == :v1 ? "=v1" : ""}", "brew outdated --json=v2"
# odeprecated "brew outdated --json#{json_version == :v1 ? "=v1" : ""}", "brew outdated --json=v2"
outdated = if args.formula? || !args.cask? outdated = if args.formula? || !args.cask?
outdated_formulae args: args outdated_formulae args: args

View File

@ -36,12 +36,6 @@ module Homebrew
description: "Include all formulae that specify <formula> as `:optional` type dependency." description: "Include all formulae that specify <formula> as `:optional` type dependency."
switch "--skip-recommended", switch "--skip-recommended",
description: "Skip all formulae that specify <formula> as `:recommended` type dependency." description: "Skip all formulae that specify <formula> as `:recommended` type dependency."
switch "--devel",
description: "Show usage of <formula> by development builds."
switch "--HEAD",
description: "Show usage of <formula> by HEAD builds."
conflicts "--devel", "--HEAD"
min_named :formula min_named :formula
end end
end end
@ -49,9 +43,6 @@ module Homebrew
def uses def uses
args = uses_args.parse args = uses_args.parse
odeprecated "brew uses --devel" if args.devel?
odeprecated "brew uses --HEAD" if args.HEAD?
Formulary.enable_factory_cache! Formulary.enable_factory_cache!
used_formulae_missing = false used_formulae_missing = false

View File

@ -6,7 +6,7 @@ module DependenciesHelpers
module Compat module Compat
def argv_includes_ignores(argv = nil) def argv_includes_ignores(argv = nil)
unless @printed_includes_ignores_warning unless @printed_includes_ignores_warning
odeprecated "Homebrew.argv_includes_ignores", "Homebrew.args_includes_ignores" odisabled "Homebrew.argv_includes_ignores", "Homebrew.args_includes_ignores"
@printed_includes_ignores_warning = true @printed_includes_ignores_warning = true
end end
args_includes_ignores(argv ? Homebrew::CLI::Args.new : Homebrew.args) args_includes_ignores(argv ? Homebrew::CLI::Args.new : Homebrew.args)

View File

@ -3,7 +3,7 @@
class NilClass class NilClass
module Compat module Compat
def chuzzle def chuzzle
odeprecated "chuzzle", "chomp.presence" odisabled ".chuzzle", "&.chomp.presence"
end end
end end

View File

@ -2,12 +2,8 @@
class String class String
module Compat module Compat
# String.chomp, but if result is empty: returns nil instead.
# Allows `chuzzle || foo` short-circuits.
def chuzzle def chuzzle
odeprecated "chuzzle", "chomp.presence" odisabled ".chuzzle", "&.chomp.presence"
s = chomp
s unless s.empty?
end end
end end

View File

@ -3,24 +3,17 @@
class Formula class Formula
module Compat module Compat
def installed? def installed?
odeprecated "Formula#installed?", odisabled "Formula#installed?",
"Formula#latest_version_installed? (or Formula#any_version_installed? )" "Formula#latest_version_installed? (or Formula#any_version_installed? )"
latest_version_installed?
end end
def prepare_patches def prepare_patches
if respond_to?(:patches) odisabled "patches", "patch do" if respond_to?(:patches)
active_spec.add_legacy_patches(patches)
odeprecated "patches", "patch do"
end
super
end end
def installed_prefix def installed_prefix
# TODO: deprecate for Homebrew 2.5 odeprecated "Formula#installed_prefix",
# odeprecated "Formula#installed_prefix", "Formula#latest_installed_prefix (or Formula#any_installed_prefix)"
# "Formula#latest_installed_prefix (or Formula#any_installed_prefix)"
latest_installed_prefix latest_installed_prefix
end end
@ -28,14 +21,12 @@ class Formula
# if the formula is not installed. # if the formula is not installed.
# @private # @private
def installed_version def installed_version
# TODO: deprecate for Homebrew 2.5 odeprecated "Formula#installed_version"
# odeprecated "Formula#installed_version"
Keg.new(latest_installed_prefix).version Keg.new(latest_installed_prefix).version
end end
def opt_or_installed_prefix_keg def opt_or_installed_prefix_keg
# TODO: deprecate for Homebrew 2.5 odeprecated "Formula#opt_or_installed_prefix_keg", "Formula#any_installed_keg"
# odeprecated "Formula#opt_or_installed_prefix_keg", "Formula#any_installed_keg"
any_installed_keg any_installed_keg
end end
end end

View File

@ -4,107 +4,30 @@ module Language
module Haskell module Haskell
module Cabal module Cabal
module Compat module Compat
def cabal_sandbox(options = {}) def cabal_sandbox(_options = {})
odeprecated "Language::Haskell::Cabal.cabal_sandbox" odisabled "Language::Haskell::Cabal.cabal_sandbox"
pwd = Pathname.pwd
home = options[:home] || pwd
# pretend HOME is elsewhere, so that ~/.cabal is kept as untouched
# as possible (except for ~/.cabal/setup-exe-cache)
# https://github.com/haskell/cabal/issues/1234
saved_home = ENV["HOME"]
ENV["HOME"] = home
system "cabal", "v1-sandbox", "init"
cabal_sandbox_bin = pwd/".cabal-sandbox/bin"
mkdir_p cabal_sandbox_bin
# make available any tools that will be installed in the sandbox
saved_path = ENV["PATH"]
ENV.prepend_path "PATH", cabal_sandbox_bin
# avoid updating the cabal package database more than once
system "cabal", "v1-update" unless (home/".cabal/packages").exist?
yield
# remove the sandbox and all build products
rm_rf [".cabal-sandbox", "cabal.sandbox.config", "dist"]
# avoid installing any Haskell libraries, as a matter of policy
rm_rf lib unless options[:keep_lib]
# restore the environment
ENV["HOME"] = saved_home
ENV["PATH"] = saved_path
end end
def cabal_sandbox_add_source(*args) def cabal_sandbox_add_source(*_args)
odeprecated "Language::Haskell::Cabal.cabal_sandbox_add_source" odisabled "Language::Haskell::Cabal.cabal_sandbox_add_source"
system "cabal", "v1-sandbox", "add-source", *args
end end
def cabal_install(*args) def cabal_install(*_args)
odeprecated "Language::Haskell::Cabal.cabal_install", odisabled "Language::Haskell::Cabal.cabal_install",
"cabal v2-install directly with std_cabal_v2_args" "cabal v2-install directly with std_cabal_v2_args"
# cabal hardcodes 64 as the maximum number of parallel jobs
# https://github.com/Homebrew/legacy-homebrew/issues/49509
make_jobs = (ENV.make_jobs > 64) ? 64 : ENV.make_jobs
# cabal-install's dependency-resolution backtracking strategy can easily
# need more than the default 2,000 maximum number of "backjumps," since
# Hackage is a fast-moving, rolling-release target. The highest known
# needed value by a formula at this time (February 2016) was 43,478 for
# git-annex, so 100,000 should be enough to avoid most gratuitous
# backjumps build failures.
system "cabal", "v1-install", "--jobs=#{make_jobs}", "--max-backjumps=100000", *args
end end
def cabal_configure(flags) def cabal_configure(_flags)
odeprecated "Language::Haskell::Cabal.cabal_configure" odisabled "Language::Haskell::Cabal.cabal_configure"
system "cabal", "v1-configure", flags
end end
def cabal_install_tools(*tools) def cabal_install_tools(*_tools)
odeprecated "Language::Haskell::Cabal.cabal_install_tools" odisabled "Language::Haskell::Cabal.cabal_install_tools"
# install tools sequentially, as some tools can depend on other tools
tools.each { |tool| cabal_install tool }
# unregister packages installed as dependencies for the tools, so
# that they can't cause dependency conflicts for the main package
rm_rf Dir[".cabal-sandbox/*packages.conf.d/"]
end end
def install_cabal_package(*args, **options) def install_cabal_package(*_args, **_options)
odeprecated "Language::Haskell::Cabal.install_cabal_package", odisabled "Language::Haskell::Cabal.install_cabal_package",
"cabal v2-update directly followed by v2-install with std_cabal_v2_args" "cabal v2-update directly followed by v2-install with std_cabal_v2_args"
cabal_sandbox do
cabal_install_tools(*options[:using]) if options[:using]
# if we have build flags, we have to pass them to cabal install to resolve the necessary
# dependencies, and call cabal configure afterwards to set the flags again for compile
flags = "--flags=#{options[:flags].join(" ")}" if options[:flags]
args_and_flags = args
args_and_flags << flags unless flags.nil?
# install dependencies in the sandbox
cabal_install "--only-dependencies", *args_and_flags
# call configure if build flags are set
cabal_configure flags unless flags.nil?
# install the main package in the destination dir
cabal_install "--prefix=#{prefix}", *args
yield if block_given?
end
end end
end end

View File

@ -4,14 +4,9 @@ module Language
module Java module Java
class << self class << self
module Compat module Compat
def java_home_cmd(version = nil) def java_home_cmd(_version = nil)
odeprecated "Language::Java.java_home_cmd", odisabled "Language::Java.java_home_cmd",
"Language::Java.java_home or Language::Java.overridable_java_home_env" "Language::Java.java_home or Language::Java.overridable_java_home_env"
# macOS provides /usr/libexec/java_home, but Linux does not.
return system_java_home_cmd(version) if OS.mac?
raise NotImplementedError
end end
end end

View File

@ -4,12 +4,9 @@ module Language
module Python module Python
class << self class << self
module Compat module Compat
def rewrite_python_shebang(python_path) def rewrite_python_shebang(_python_path)
odeprecated "Language::Python.rewrite_python_shebang", odisabled "Language::Python.rewrite_python_shebang",
"Utils::Shebang.rewrite_shebang and Shebang.python_shebang_rewrite_info(python_path)" "Utils::Shebang.rewrite_shebang and Shebang.python_shebang_rewrite_info(python_path)"
Pathname.pwd.find do |f|
Utils::Shebang.rewrite_shebang(Shebang.python_shebang_rewrite_info(python_path), f)
end
end end
end end

View File

@ -5,22 +5,15 @@ module OS
class << self class << self
module Compat module Compat
def preferred_arch def preferred_arch
odeprecated "MacOS.preferred_arch", "Hardware::CPU.arch (or ideally let the compiler handle it)" odisabled "MacOS.preferred_arch", "Hardware::CPU.arch (or ideally let the compiler handle it)"
if Hardware::CPU.is_64_bit?
Hardware::CPU.arch_64_bit
else
Hardware::CPU.arch_32_bit
end
end end
def tcc_db def tcc_db
odeprecated "MacOS.tcc_db" odisabled "MacOS.tcc_db"
@tcc_db ||= Pathname.new("/Library/Application Support/com.apple.TCC/TCC.db")
end end
def pre_mavericks_accessibility_dotfile def pre_mavericks_accessibility_dotfile
odeprecated "MacOS.pre_mavericks_accessibility_dotfile" odisabled "MacOS.pre_mavericks_accessibility_dotfile"
@pre_mavericks_accessibility_dotfile ||= Pathname.new("/private/var/db/.AccessibilityAPIEnabled")
end end
end end

View File

@ -229,7 +229,7 @@ module Homebrew
@problems = [] @problems = []
@new_formula_problems = [] @new_formula_problems = []
@text = FormulaText.new(formula.path) @text = FormulaText.new(formula.path)
@specs = %w[stable devel head].map { |s| formula.send(s) }.compact @specs = %w[stable head].map { |s| formula.send(s) }.compact
@spdx_license_data = options[:spdx_license_data] @spdx_license_data = options[:spdx_license_data]
@spdx_exception_data = options[:spdx_exception_data] @spdx_exception_data = options[:spdx_exception_data]
end end
@ -718,9 +718,8 @@ module Homebrew
def audit_specs def audit_specs
problem "Head-only (no stable download)" if head_only?(formula) problem "Head-only (no stable download)" if head_only?(formula)
problem "Devel-only (no stable download)" if devel_only?(formula)
%w[Stable Devel HEAD].each do |name| %w[Stable HEAD].each do |name|
spec_name = name.downcase.to_sym spec_name = name.downcase.to_sym
next unless spec = formula.send(spec_name) next unless spec = formula.send(spec_name)
@ -745,28 +744,16 @@ module Homebrew
) )
end end
%w[Stable Devel].each do |name| if stable = formula.stable
next unless spec = formula.send(name.downcase) version = stable.version
problem "Stable: version (#{version}) is set to a string without a digit" if version.to_s !~ /\d/
version = spec.version
problem "#{name}: version (#{version}) is set to a string without a digit" if version.to_s !~ /\d/
if version.to_s.start_with?("HEAD") if version.to_s.start_with?("HEAD")
problem "#{name}: non-HEAD version name (#{version}) should not begin with HEAD" problem "Stable: non-HEAD version name (#{version}) should not begin with HEAD"
end
end
if formula.stable && formula.devel
if formula.devel.version < formula.stable.version
problem "devel version #{formula.devel.version} is older than stable version #{formula.stable.version}"
elsif formula.devel.version == formula.stable.version
problem "stable and devel versions are identical"
end end
end end
return unless @core_tap return unless @core_tap
problem "Formulae in homebrew/core should not have a `devel` spec" if formula.devel
if formula.head && @versioned_formula if formula.head && @versioned_formula
head_spec_message = "Versioned formulae should not have a `HEAD` spec" head_spec_message = "Versioned formulae should not have a `HEAD` spec"
problem head_spec_message unless VERSIONED_HEAD_SPEC_ALLOWLIST.include?(formula.name) problem head_spec_message unless VERSIONED_HEAD_SPEC_ALLOWLIST.include?(formula.name)
@ -990,11 +977,7 @@ module Homebrew
end end
def head_only?(formula) def head_only?(formula)
formula.head && formula.devel.nil? && formula.stable.nil? formula.head && formula.stable.nil?
end
def devel_only?(formula)
formula.devel && formula.stable.nil?
end end
end end

View File

@ -54,8 +54,8 @@ module Homebrew
Formula.installed Formula.installed
elsif args.all? elsif args.all?
Formula Formula
elsif args.formulae.present? elsif (formulae_args = args.named.to_formulae) && formulae_args.present?
args.formulae formulae_args
elsif File.exist?(WATCHLIST_PATH) elsif File.exist?(WATCHLIST_PATH)
begin begin
Pathname.new(WATCHLIST_PATH).read.lines.map do |line| Pathname.new(WATCHLIST_PATH).read.lines.map do |line|

View File

@ -43,300 +43,6 @@ module Homebrew
end end
def pull def pull
odeprecated "brew pull", "hub checkout" odisabled "brew pull", "hub checkout"
odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase"
args = pull_args.parse
# Passthrough Git environment variables for e.g. git am
Utils::Git.set_name_email!(author: false, committer: true)
# Depending on user configuration, git may try to invoke gpg.
if Utils.popen_read("git config --get --bool commit.gpgsign").chomp == "true"
begin
gnupg = Formula["gnupg"]
rescue FormulaUnavailableError # rubocop:disable Lint/SuppressedException
else
if gnupg.any_version_installed?
path = PATH.new(ENV.fetch("PATH"))
path.prepend(gnupg.any_installed_prefix/"bin")
ENV["PATH"] = path
end
end
end
do_bump = args.bump? && !args.clean?
tap = nil
args.named.each do |arg|
arg = "#{CoreTap.instance.default_remote}/pull/#{arg}" if arg.to_i.positive?
if (api_match = arg.match HOMEBREW_PULL_API_REGEX)
_, user, repo, issue = *api_match
url = "https://github.com/#{user}/#{repo}/pull/#{issue}"
tap = Tap.fetch(user, repo) if repo.match?(HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX)
elsif (url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX)
url, user, repo, issue = *url_match
tap = Tap.fetch(user, repo) if repo.match?(HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX)
else
odie "Not a GitHub pull request or commit: #{arg}"
end
odie "No pull request detected!" if issue.blank?
if tap
tap.install unless tap.installed?
Dir.chdir tap.path
else
Dir.chdir HOMEBREW_REPOSITORY
end
# The cache directory seems like a good place to put patches.
HOMEBREW_CACHE.mkpath
# Store current revision and branch
orig_revision = `git rev-parse --short HEAD`.strip
branch = `git symbolic-ref --short HEAD`.strip
if branch != "master" && !args.clean? && !args.branch_okay?
opoo "Current branch is #{branch}: do you need to pull inside master?"
end
patch_puller = PatchPuller.new(url, args)
patch_puller.fetch_patch
patch_changes = files_changed_in_patch(patch_puller.patchpath, tap)
is_bumpable = patch_changes[:formulae].length == 1 && patch_changes[:others].empty?
check_bumps(patch_changes) if do_bump
old_versions = current_versions_from_info_external(patch_changes[:formulae].first) if is_bumpable
patch_puller.apply_patch
end_revision = `git rev-parse --short HEAD`.strip
changed_formulae_names = []
if tap
Utils.popen_read(
"git", "diff-tree", "-r", "--name-only",
"--diff-filter=AM", orig_revision, end_revision, "--", tap.formula_dir.to_s
).each_line do |line|
next unless line.end_with? ".rb\n"
name = "#{tap.name}/#{File.basename(line.chomp, ".rb")}"
changed_formulae_names << name
end
end
changed_formulae_names.each do |name|
next if Homebrew::EnvConfig.disable_load_formula?
begin
f = Formula[name]
rescue Exception # rubocop:disable Lint/RescueException
# Make sure we catch syntax errors.
next
end
next unless f.stable
stable_urls = [f.stable.url] + f.stable.mirrors
stable_urls.grep(%r{^https://dl.bintray.com/homebrew/mirror/}) do |mirror_url|
check_bintray_mirror(f.full_name, mirror_url)
end
end
orig_message = message = `git log HEAD^.. --format=%B`
if issue && !args.clean?
ohai "Patch closes issue ##{issue}"
close_message = "Closes ##{issue}."
# If this is a pull request, append a close message.
message += "\n#{close_message}" unless message.include? close_message
end
if changed_formulae_names.empty?
odie "Cannot bump: no changed formulae found after applying patch" if do_bump
is_bumpable = false
end
is_bumpable = false if args.clean?
is_bumpable = false if Homebrew::EnvConfig.disable_load_formula?
if is_bumpable
formula = Formula[changed_formulae_names.first]
new_versions = current_versions_from_info_external(patch_changes[:formulae].first)
orig_subject = message.empty? ? "" : message.lines.first.chomp
bump_subject = subject_for_bump(formula, old_versions, new_versions)
if do_bump
odie "No version changes found for #{formula.name}" if bump_subject.nil?
unless orig_subject == bump_subject
ohai "New bump commit subject: #{bump_subject}"
pbcopy bump_subject unless args.no_pbcopy?
message = "#{bump_subject}\n\n#{message}"
end
elsif bump_subject != orig_subject && !bump_subject.nil?
opoo "Nonstandard bump subject: #{orig_subject}"
opoo "Subject should be: #{bump_subject}"
end
end
if message != orig_message && !args.clean?
safe_system "git", "commit", "--amend", "--signoff", "--allow-empty", "-q", "-m", message
end
ohai "Patch changed:"
safe_system "git", "diff-tree", "-r", "--stat", orig_revision, end_revision
end
end
def check_bumps(patch_changes)
if patch_changes[:formulae].empty?
odie "No changed formulae found to bump"
elsif patch_changes[:formulae].length > 1
odie "Can only bump one changed formula; bumped #{patch_changes[:formulae]}"
elsif !patch_changes[:others].empty?
odie "Cannot bump if non-formula files are changed"
end
end
class PatchPuller
attr_reader :base_url, :patch_url, :patchpath
def initialize(url, args, description = nil)
@base_url = url
# GitHub provides commits/pull-requests raw patches using this URL.
@patch_url = "#{url}.patch"
@patchpath = HOMEBREW_CACHE + File.basename(patch_url)
@description = description
@args = args
end
def fetch_patch
extra_msg = @description ? "(#{@description})" : nil
ohai "Fetching patch #{extra_msg}"
puts "Patch: #{patch_url}"
curl_download patch_url, to: patchpath
end
def apply_patch
# Applies a patch previously downloaded with fetch_patch()
# Deletes the patch file as a side effect, regardless of success
ohai "Applying patch"
patch_args = []
# Normally we don't want whitespace errors, but squashing them can break
# patches so an option is provided to skip this step.
patch_args << if @args.ignore_whitespace? || @args.clean?
"--whitespace=nowarn"
else
"--whitespace=fix"
end
# Fall back to three-way merge if patch does not apply cleanly
patch_args << "-3"
patch_args << patchpath
begin
safe_system "git", "am", *patch_args
rescue ErrorDuringExecution
if @args.resolve?
odie "Patch failed to apply: try to resolve it."
else
system "git", "am", "--abort"
odie "Patch failed to apply: aborted."
end
ensure
patchpath.unlink
end
end
end
# List files changed by a patch, partitioned in to those that are (probably)
# formula definitions, and those which aren't. Only applies to patches on
# Homebrew core or taps, based simply on relative pathnames of affected files.
def files_changed_in_patch(patchfile, tap)
files = []
formulae = []
others = []
File.foreach(patchfile) do |line|
files << Regexp.last_match(1) if line =~ %r{^\+\+\+ b/(.*)}
end
files.each do |file|
if tap&.formula_file?(file)
formula_name = File.basename(file, ".rb")
formulae << formula_name unless formulae.include?(formula_name)
else
others << file
end
end
{ files: files, formulae: formulae, others: others }
end
# Get current formula versions without loading formula definition in this process.
# Returns info as a hash (type => version), for pull.rb's internal use.
# Uses special key `:nonexistent => true` for nonexistent formulae.
def current_versions_from_info_external(formula_name)
info = FormulaInfo.lookup(formula_name)
versions = {}
if info
[:stable, :devel, :head].each do |spec_type|
versions[spec_type] = info.version(spec_type)
end
else
versions[:nonexistent] = true
end
versions
end
def subject_for_bump(formula, old, new)
if old[:nonexistent]
# New formula
headline_ver = if new[:stable]
new[:stable]
elsif new[:devel]
new[:devel]
else
new[:head]
end
subject = "#{formula.name} #{headline_ver} (new formula)"
else
# Update to existing formula
subject_strs = []
formula_name_str = formula.name
if old[:stable] != new[:stable]
if new[:stable].nil?
subject_strs << "remove stable"
formula_name_str += ":" # just for cosmetics
else
subject_strs << new[:stable]
end
end
if old[:devel] != new[:devel]
if new[:devel].nil?
# Only bother mentioning if there's no accompanying stable change
if !new[:stable].nil? && old[:stable] == new[:stable]
subject_strs << "remove devel"
formula_name_str += ":" # just for cosmetics
end
else
subject_strs << "#{new[:devel]} (devel)"
end
end
subject = subject_strs.empty? ? nil : "#{formula_name_str} #{subject_strs.join(", ")}"
end
subject
end
def pbcopy(text)
Utils.popen_write("pbcopy") { |io| io.write text }
end
def check_bintray_mirror(name, url)
headers, = curl_output("--connect-timeout", "15", "--location", "--head", url)
status_code = headers.scan(%r{^HTTP/.* (\d+)}).last.first
return if status_code.start_with?("2")
opoo "The Bintray mirror #{url} is not reachable (HTTP status code #{status_code})."
opoo "Do you need to upload it with `brew mirror #{name}`?"
end end
end end

View File

@ -85,11 +85,7 @@ module Homebrew
#{f.path} #{f.path}
].concat(args.options_only) ].concat(args.options_only)
if f.head? exec_args << "--HEAD" if f.head?
exec_args << "--HEAD"
elsif f.devel?
exec_args << "--devel"
end
Utils.safe_fork do Utils.safe_fork do
if Sandbox.available? if Sandbox.available?

View File

@ -113,12 +113,10 @@ class Formula
# @private # @private
attr_reader :stable attr_reader :stable
# The development {SoftwareSpec} for this {Formula}.
# Installed when using `brew install --devel`
# `nil` if there is no development version.
# @see #stable
# @private # @private
attr_reader :devel def devel
odisabled "Formula#devel"
end
# The HEAD {SoftwareSpec} for this {Formula}. # The HEAD {SoftwareSpec} for this {Formula}.
# Installed when using `brew install --HEAD` # Installed when using `brew install --HEAD`
@ -136,7 +134,7 @@ class Formula
protected :active_spec protected :active_spec
# A symbol to indicate currently active {SoftwareSpec}. # A symbol to indicate currently active {SoftwareSpec}.
# It's either :stable, :devel or :head # It's either :stable or :head
# @see #active_spec # @see #active_spec
# @private # @private
attr_reader :active_spec_sym attr_reader :active_spec_sym
@ -207,14 +205,11 @@ class Formula
@full_alias_name = full_name_with_optional_tap(@alias_name) @full_alias_name = full_name_with_optional_tap(@alias_name)
spec_eval :stable spec_eval :stable
spec_eval :devel
spec_eval :head spec_eval :head
@active_spec = determine_active_spec(spec) @active_spec = determine_active_spec(spec)
@active_spec_sym = if head? @active_spec_sym = if head?
:head :head
elsif devel?
:devel
else else
:stable :stable
end end
@ -258,7 +253,7 @@ class Formula
end end
def determine_active_spec(requested) def determine_active_spec(requested)
spec = send(requested) || stable || devel || head spec = send(requested) || stable || head
spec || raise(FormulaSpecificationError, "formulae require at least a URL") spec || raise(FormulaSpecificationError, "formulae require at least a URL")
end end
@ -326,10 +321,9 @@ class Formula
active_spec == stable active_spec == stable
end end
# Is the currently active {SoftwareSpec} a {#devel} build?
# @private # @private
def devel? def devel?
active_spec == devel odisabled "Formula#devel?"
end end
# Is the currently active {SoftwareSpec} a {#head} build? # Is the currently active {SoftwareSpec} a {#head} build?
@ -533,7 +527,6 @@ class Formula
return true if tab.version_scheme < version_scheme return true if tab.version_scheme < version_scheme
return true if stable && tab.stable_version && tab.stable_version < stable.version return true if stable && tab.stable_version && tab.stable_version < stable.version
return true if devel && tab.devel_version && tab.devel_version < devel.version
return false unless fetch_head return false unless fetch_head
return false unless head&.downloader.is_a?(VCSDownloadStrategy) return false unless head&.downloader.is_a?(VCSDownloadStrategy)
@ -544,14 +537,11 @@ class Formula
end end
end end
# The latest prefix for this formula. Checks for {#head}, then {#devel} # The latest prefix for this formula. Checks for {#head} and then {#stable}'s {#prefix}
# and then {#stable}'s {#prefix}
# @private # @private
def latest_installed_prefix def latest_installed_prefix
if head && (head_version = latest_head_version) && !head_version_outdated?(head_version) if head && (head_version = latest_head_version) && !head_version_outdated?(head_version)
latest_head_prefix latest_head_prefix
elsif devel && (devel_prefix = prefix(PkgVersion.new(devel.version, revision))).directory?
devel_prefix
elsif stable && (stable_prefix = prefix(PkgVersion.new(stable.version, revision))).directory? elsif stable && (stable_prefix = prefix(PkgVersion.new(stable.version, revision))).directory?
stable_prefix stable_prefix
else else
@ -1713,7 +1703,6 @@ class Formula
"homepage" => homepage, "homepage" => homepage,
"versions" => { "versions" => {
"stable" => stable&.version&.to_s, "stable" => stable&.version&.to_s,
"devel" => devel&.version&.to_s,
"head" => head&.version&.to_s, "head" => head&.version&.to_s,
"bottle" => !bottle_specification.checksums.empty?, "bottle" => !bottle_specification.checksums.empty?,
}, },
@ -1750,18 +1739,15 @@ class Formula
"disabled" => disabled?, "disabled" => disabled?,
} }
%w[stable devel].each do |spec_sym| if stable
next unless spec = send(spec_sym) hsh["urls"]["stable"] = {
"url" => stable.url,
hsh["urls"][spec_sym] = { "tag" => stable.specs[:tag],
"url" => spec.url, "revision" => stable.specs[:revision],
"tag" => spec.specs[:tag],
"revision" => spec.specs[:revision],
} }
next unless spec.bottle_defined? if bottle_defined?
bottle_spec = stable.bottle_specification
bottle_spec = spec.bottle_specification
bottle_info = { bottle_info = {
"rebuild" => bottle_spec.rebuild, "rebuild" => bottle_spec.rebuild,
"cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? cellar.inspect : cellar, "cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? cellar.inspect : cellar,
@ -1777,7 +1763,8 @@ class Formula
checksum.hash_type.to_s => checksum.hexdigest, checksum.hash_type.to_s => checksum.hexdigest,
} }
end end
hsh["bottle"][spec_sym] = bottle_info hsh["bottle"]["stable"] = bottle_info
end
end end
hsh["options"] = options.map do |opt| hsh["options"] = options.map do |opt|
@ -2203,18 +2190,9 @@ class Formula
when :test when :test
define_method(:test_defined?) { true } define_method(:test_defined?) { true }
when :patches when :patches
odeprecated "a Formula#patches definition", "'patch do' block calls" odisabled "a Formula#patches definition", "'patch do' block calls"
when :options when :options
odeprecated "a Formula#options definition", "'option do' block calls" odisabled "a Formula#options definition", "'option do' block calls"
instance = allocate
specs.each do |spec|
instance.options.each do |opt, desc|
spec.option(opt[/^--(.+)$/, 1], desc)
end
end
remove_method(:options)
end end
end end
@ -2259,8 +2237,7 @@ class Formula
@licenses @licenses
else else
if args.is_a? Array if args.is_a? Array
# TODO: enable for next major/minor release odeprecated "`license [...]`", "`license any_of: [...]`"
# odeprecated "`license [...]`", "`license any_of: [...]`"
args = { any_of: args } args = { any_of: args }
end end
@licenses = args @licenses = args
@ -2318,10 +2295,10 @@ class Formula
# <pre>version_scheme 1</pre> # <pre>version_scheme 1</pre>
attr_rw :version_scheme attr_rw :version_scheme
# A list of the {.stable}, {.devel} and {.head} {SoftwareSpec}s. # A list of the {.stable} and {.head} {SoftwareSpec}s.
# @private # @private
def specs def specs
@specs ||= [stable, devel, head].freeze @specs ||= [stable, head].freeze
end end
# @!attribute [w] url # @!attribute [w] url
@ -2449,25 +2426,9 @@ class Formula
@stable.instance_eval(&block) @stable.instance_eval(&block)
end end
# @!attribute [w] devel
# Adds a {.devel} {SoftwareSpec}.
# This can be installed by passing the `--devel` option to allow
# installing non-stable (e.g. beta) versions of software.
#
# <pre>devel do
# url "https://example.com/archive-2.0-beta.tar.gz"
# sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7"
#
# depends_on "cairo"
# depends_on "pixman"
# end</pre>
# @private # @private
def devel(&block) def devel
@devel ||= SoftwareSpec.new(flags: build_flags) odisabled "'devel' blocks in formulae", "'head' blocks or @-versioned formulae"
return @devel unless block_given?
odeprecated "'devel' blocks in formulae", "'head' blocks or @-versioned formulae"
@devel.instance_eval(&block)
end end
# @!attribute [w] head # @!attribute [w] head
@ -2784,8 +2745,7 @@ class Formula
# <pre>deprecate! date: "2020-08-27", because: :unmaintained</pre> # <pre>deprecate! date: "2020-08-27", because: :unmaintained</pre>
# <pre>deprecate! date: "2020-08-27", because: "it has been replaced by"</pre> # <pre>deprecate! date: "2020-08-27", because: "it has been replaced by"</pre>
def deprecate!(date: nil, because: nil) def deprecate!(date: nil, because: nil)
# TODO: enable for next major/minor release odeprecated "`deprecate!` without a reason", "`deprecate! because: \"reason\"`" if because.blank?
# odeprecated "`deprecate!` without a reason", "`deprecate! because: \"reason\"`" if because.blank?
return if date.present? && Date.parse(date) > Date.today return if date.present? && Date.parse(date) > Date.today
@ -2811,8 +2771,7 @@ class Formula
# <pre>disable! date: "2020-08-27", because: :does_not_build</pre> # <pre>disable! date: "2020-08-27", because: :does_not_build</pre>
# <pre>disable! date: "2020-08-27", because: "has been replaced by foo"</pre> # <pre>disable! date: "2020-08-27", because: "has been replaced by foo"</pre>
def disable!(date: nil, because: nil) def disable!(date: nil, because: nil)
# TODO: enable for next major/minor release odeprecated "`disable!` without a reason", "`disable! because: \"reason\"`" if because.blank?
# odeprecated "`disable!` without a reason", "`disable! because: \"reason\"`" if because.blank?
if date.present? && Date.parse(date) > Date.today if date.present? && Date.parse(date) > Date.today
@deprecation_reason = because if because.present? @deprecation_reason = because if because.present?

View File

@ -605,8 +605,6 @@ class FormulaInstaller
def display_options(formula) def display_options(formula)
options = if formula.head? options = if formula.head?
["--HEAD"] ["--HEAD"]
elsif formula.devel?
["--devel"]
else else
[] []
end end
@ -809,11 +807,7 @@ class FormulaInstaller
args << "--env=std" args << "--env=std"
end end
if formula.head? args << "--HEAD" if formula.head?
args << "--HEAD"
elsif formula.devel?
args << "--devel"
end
args args
end end

View File

@ -220,10 +220,10 @@ module Formulary
def load_file(flags:) def load_file(flags:)
if url =~ %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(/Formula)?/([\w+-.@]+).rb} if url =~ %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(/Formula)?/([\w+-.@]+).rb}
formula_name = Regexp.last_match(2) formula_name = Regexp.last_match(2)
odeprecated "Installation of #{formula_name} from a GitHub commit URL", odisabled "Installation of #{formula_name} from a GitHub commit URL",
"'brew extract #{formula_name}' to stable tap on GitHub" "'brew extract #{formula_name}' to stable tap on GitHub"
elsif url.match?(%r{^(https?|ftp)://}) elsif url.match?(%r{^(https?|ftp)://})
odeprecated "Non-checksummed download of #{name} formula file from an arbitrary URL", odisabled "Non-checksummed download of #{name} formula file from an arbitrary URL",
"'brew extract' or 'brew create' and 'brew tap-new' to create a "\ "'brew extract' or 'brew create' and 'brew tap-new' to create a "\
"formula file in a tap on GitHub" "formula file in a tap on GitHub"
end end

View File

@ -84,7 +84,7 @@ class Livecheck
@url = case val @url = case val
when nil when nil
return @url return @url
when :head, :stable, :devel when :head, :stable
@formula.send(val).url @formula.send(val).url
when :homepage when :homepage
@formula.homepage @formula.homepage

View File

@ -126,7 +126,6 @@ class Options
f.options.sort_by(&:flag).each do |opt| f.options.sort_by(&:flag).each do |opt|
puts "#{opt.flag}\n\t#{opt.description}" puts "#{opt.flag}\n\t#{opt.description}"
end end
puts "--devel\n\tInstall development version #{f.devel.version}" if f.devel
puts "--HEAD\n\tInstall HEAD version" if f.head puts "--HEAD\n\tInstall HEAD version" if f.head
end end
end end

View File

@ -191,25 +191,8 @@ end
# #
# @api private # @api private
class LegacyPatch < ExternalPatch class LegacyPatch < ExternalPatch
def initialize(strip, url) def initialize(strip, _url)
odeprecated "legacy patches", "'patch do' blocks" odisabled "legacy patches", "'patch do' blocks"
super(strip) super(strip)
resource.url(url)
resource.download_strategy = CurlDownloadStrategy
end
def fetch
clear_cache
super
end
def verify_download_integrity(_fn)
# no-op
end
def apply
super
ensure
clear_cache
end end
end end

View File

@ -20,7 +20,7 @@ class MacOSRequirement < Requirement
rescue MacOSVersionError => e rescue MacOSVersionError => e
raise if e.version != :mavericks raise if e.version != :mavericks
odeprecated "depends_on :macos => :mavericks" odisabled "depends_on :macos => :mavericks"
end end
@comparator = comparator @comparator = comparator

View File

@ -32,7 +32,6 @@ module RuboCop
[{ name: :livecheck, type: :block_call }], [{ name: :livecheck, type: :block_call }],
[{ name: :bottle, type: :block_call }], [{ name: :bottle, type: :block_call }],
[{ name: :pour_bottle?, type: :block_call }], [{ name: :pour_bottle?, type: :block_call }],
[{ name: :devel, type: :block_call }],
[{ name: :head, type: :block_call }], [{ name: :head, type: :block_call }],
[{ name: :bottle, type: :method_call }], [{ name: :bottle, type: :method_call }],
[{ name: :keg_only, type: :method_call }], [{ name: :keg_only, type: :method_call }],

View File

@ -10,13 +10,13 @@ module RuboCop
# - `url|checksum|mirror` should be inside `stable` block # - `url|checksum|mirror` should be inside `stable` block
# - `head` and `head do` should not be simultaneously present # - `head` and `head do` should not be simultaneously present
# - `bottle :unneeded`/`:disable` and `bottle do` should not be simultaneously present # - `bottle :unneeded`/`:disable` and `bottle do` should not be simultaneously present
# - `stable do` should not be present without a `head` or `devel` spec # - `stable do` should not be present without a `head` spec
# #
# @api private # @api private
class ComponentsRedundancy < FormulaCop class ComponentsRedundancy < FormulaCop
HEAD_MSG = "`head` and `head do` should not be simultaneously present" HEAD_MSG = "`head` and `head do` should not be simultaneously present"
BOTTLE_MSG = "`bottle :modifier` and `bottle do` should not be simultaneously present" BOTTLE_MSG = "`bottle :modifier` and `bottle do` should not be simultaneously present"
STABLE_MSG = "`stable do` should not be present without a `head` or `devel` spec" STABLE_MSG = "`stable do` should not be present without a `head` spec"
def audit_formula(_node, _class_node, _parent_class_node, body_node) def audit_formula(_node, _class_node, _parent_class_node, body_node)
urls = find_method_calls_by_name(body_node, :url) urls = find_method_calls_by_name(body_node, :url)
@ -46,8 +46,7 @@ module RuboCop
find_block(body_node, :bottle) find_block(body_node, :bottle)
return if method_called?(body_node, :head) || return if method_called?(body_node, :head) ||
find_block(body_node, :head) || find_block(body_node, :head)
find_block(body_node, :devel)
problem STABLE_MSG if stable_block problem STABLE_MSG if stable_block
end end

View File

@ -13,7 +13,7 @@ module RuboCop
def audit_formula(_node, _class_node, _parent_class_node, body_node) def audit_formula(_node, _class_node, _parent_class_node, body_node)
check_dependency_nodes_order(body_node) check_dependency_nodes_order(body_node)
check_uses_from_macos_nodes_order(body_node) check_uses_from_macos_nodes_order(body_node)
[:devel, :head, :stable].each do |block_name| [:head, :stable].each do |block_name|
block = find_block(body_node, block_name) block = find_block(body_node, block_name)
next unless block next unless block

View File

@ -43,7 +43,6 @@ class Tab < OpenStruct
"spec" => formula.active_spec_sym.to_s, "spec" => formula.active_spec_sym.to_s,
"versions" => { "versions" => {
"stable" => formula.stable&.version.to_s, "stable" => formula.stable&.version.to_s,
"devel" => formula.devel&.version.to_s,
"head" => formula.head&.version.to_s, "head" => formula.head&.version.to_s,
"version_scheme" => formula.version_scheme, "version_scheme" => formula.version_scheme,
}, },
@ -93,7 +92,6 @@ class Tab < OpenStruct
if attributes["source"]["versions"].nil? if attributes["source"]["versions"].nil?
attributes["source"]["versions"] = { attributes["source"]["versions"] = {
"stable" => nil, "stable" => nil,
"devel" => nil,
"head" => nil, "head" => nil,
"version_scheme" => 0, "version_scheme" => 0,
} }
@ -163,7 +161,6 @@ class Tab < OpenStruct
"spec" => f.active_spec_sym.to_s, "spec" => f.active_spec_sym.to_s,
"versions" => { "versions" => {
"stable" => f.stable&.version.to_s, "stable" => f.stable&.version.to_s,
"devel" => f.devel&.version.to_s,
"head" => f.head&.version.to_s, "head" => f.head&.version.to_s,
"version_scheme" => f.version_scheme, "version_scheme" => f.version_scheme,
}, },
@ -195,7 +192,6 @@ class Tab < OpenStruct
"spec" => "stable", "spec" => "stable",
"versions" => { "versions" => {
"stable" => nil, "stable" => nil,
"devel" => nil,
"head" => nil, "head" => nil,
"version_scheme" => 0, "version_scheme" => 0,
}, },
@ -234,10 +230,12 @@ class Tab < OpenStruct
end end
def universal? def universal?
odeprecated "Tab#universal?"
include?("universal") include?("universal")
end end
def cxx11? def cxx11?
odeprecated "Tab#cxx11?"
include?("c++11") include?("c++11")
end end
@ -246,7 +244,7 @@ class Tab < OpenStruct
end end
def devel? def devel?
spec == :devel odisabled "Tab#devel?"
end end
def stable? def stable?
@ -314,7 +312,7 @@ class Tab < OpenStruct
end end
def devel_version def devel_version
Version.create(versions["devel"]) if versions["devel"] odisabled "Tab#devel_version"
end end
def head_version def head_version

View File

@ -14,12 +14,6 @@ describe BuildOptions do
let(:opts) { Options.create(%w[--with-foo --with-bar --without-baz --without-qux]) } let(:opts) { Options.create(%w[--with-foo --with-bar --without-baz --without-qux]) }
let(:bad_args) { Options.create(%w[--with-foo --with-bar --without-bas --without-qux --without-abc]) } let(:bad_args) { Options.create(%w[--with-foo --with-bar --without-bas --without-qux --without-abc]) }
specify "#include?" do
expect(subject).to include("with-foo")
expect(subject).not_to include("with-qux")
expect(subject).not_to include("--with-foo")
end
specify "#with?" do specify "#with?" do
expect(subject).to be_built_with("foo") expect(subject).to be_built_with("foo")
expect(subject).to be_built_with("bar") expect(subject).to be_built_with("bar")

View File

@ -11,17 +11,18 @@ describe "brew outdated", :integration_test do
setup_test_formula "testball" setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
expected_json = [ expected_json = {
{ formulae: [{
name: "testball", name: "testball",
installed_versions: ["0.0.1"], installed_versions: ["0.0.1"],
current_version: "0.1", current_version: "0.1",
pinned: false, pinned: false,
pinned_version: nil, pinned_version: nil,
}, }],
].to_json casks: [],
}.to_json
expect { brew "outdated", "--json=v1" } expect { brew "outdated", "--json=v2" }
.to output("#{expected_json}\n").to_stdout .to output("#{expected_json}\n").to_stdout
.and be_a_success .and be_a_success
end end

View File

@ -1,20 +0,0 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
describe "Homebrew.pull_args" do
it_behaves_like "parseable arguments"
end
describe "brew pull", :integration_test do
it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network do
HOMEBREW_REPOSITORY.cd do
system "git", "init"
system "git", "remote", "add", "origin", "https://github.com/Homebrew/brew"
end
expect { brew "pull", "https://github.com/Homebrew/brew/pull/1249" }
.to output(/Fetching patch/).to_stdout
.and be_a_failure
end
end

View File

@ -24,7 +24,7 @@ describe Homebrew::Livecheck do
desc "Deprecated test formula" desc "Deprecated test formula"
homepage "https://brew.sh" homepage "https://brew.sh"
url "https://brew.sh/test-0.0.1.tgz" url "https://brew.sh/test-0.0.1.tgz"
deprecate! deprecate! because: :unmaintained
end end
end end

View File

@ -17,7 +17,6 @@ describe Formula do
end end
expect(f.class.stable.deps.first.name).to eq("foo") expect(f.class.stable.deps.first.name).to eq("foo")
expect(f.class.devel.deps.first.name).to eq("foo")
expect(f.class.head.deps.first.name).to eq("foo") expect(f.class.head.deps.first.name).to eq("foo")
end end
@ -29,7 +28,6 @@ describe Formula do
end end
expect(f.class.stable.deps.first.name).to eq("foo") expect(f.class.stable.deps.first.name).to eq("foo")
expect(f.class.devel.deps.first.name).to eq("foo")
expect(f.class.head.deps.first.name).to eq("foo") expect(f.class.head.deps.first.name).to eq("foo")
end end
end end

View File

@ -18,10 +18,8 @@ describe Formula do
end end
expect(f.class.stable.deps).to be_empty expect(f.class.stable.deps).to be_empty
expect(f.class.devel.deps).to be_empty
expect(f.class.head.deps).to be_empty expect(f.class.head.deps).to be_empty
expect(f.class.stable.uses_from_macos_elements.first).to eq("foo") expect(f.class.stable.uses_from_macos_elements.first).to eq("foo")
expect(f.class.devel.uses_from_macos_elements.first).to eq("foo")
expect(f.class.head.uses_from_macos_elements.first).to eq("foo") expect(f.class.head.uses_from_macos_elements.first).to eq("foo")
end end
@ -33,10 +31,8 @@ describe Formula do
end end
expect(f.class.stable.deps.first.name).to eq("foo") expect(f.class.stable.deps.first.name).to eq("foo")
expect(f.class.devel.deps.first.name).to eq("foo")
expect(f.class.head.deps.first.name).to eq("foo") expect(f.class.head.deps.first.name).to eq("foo")
expect(f.class.stable.uses_from_macos_elements).to be_empty expect(f.class.stable.uses_from_macos_elements).to be_empty
expect(f.class.devel.uses_from_macos_elements).to be_empty
expect(f.class.head.uses_from_macos_elements).to be_empty expect(f.class.head.uses_from_macos_elements).to be_empty
end end
end end

View File

@ -15,7 +15,7 @@ describe RuboCop::Cop::FormulaAudit::ComponentsRedundancy do
# stuff # stuff
end end
devel do head do
# stuff # stuff
end end
end end
@ -72,19 +72,5 @@ describe RuboCop::Cop::FormulaAudit::ComponentsRedundancy do
end end
RUBY RUBY
end end
it "When `stable do` is present with a `devel` block" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
stable do
# stuff
end
devel do
# stuff
end
end
RUBY
end
end end
end end

View File

@ -38,7 +38,6 @@ describe Tab do
"spec" => "stable", "spec" => "stable",
"versions" => { "versions" => {
"stable" => "0.10", "stable" => "0.10",
"devel" => "0.14",
"head" => "HEAD-1111111", "head" => "HEAD-1111111",
}, },
}, },
@ -66,14 +65,12 @@ describe Tab do
expect(tab).not_to be_built_as_bottle expect(tab).not_to be_built_as_bottle
expect(tab).not_to be_poured_from_bottle expect(tab).not_to be_poured_from_bottle
expect(tab).to be_stable expect(tab).to be_stable
expect(tab).not_to be_devel
expect(tab).not_to be_head expect(tab).not_to be_head
expect(tab.tap).to be nil expect(tab.tap).to be nil
expect(tab.time).to be nil expect(tab.time).to be nil
expect(tab.HEAD).to be nil expect(tab.HEAD).to be nil
expect(tab.runtime_dependencies).to be nil expect(tab.runtime_dependencies).to be nil
expect(tab.stable_version).to be nil expect(tab.stable_version).to be nil
expect(tab.devel_version).to be nil
expect(tab.head_version).to be nil expect(tab.head_version).to be nil
expect(tab.cxxstdlib.compiler).to eq(DevelopmentTools.default_compiler) expect(tab.cxxstdlib.compiler).to eq(DevelopmentTools.default_compiler)
expect(tab.cxxstdlib.type).to be nil expect(tab.cxxstdlib.type).to be nil
@ -92,11 +89,6 @@ describe Tab do
expect(subject).not_to be_built_with("baz") expect(subject).not_to be_built_with("baz")
end end
specify "#universal?" do
tab = described_class.new(used_options: %w[--universal])
expect(tab).to be_universal
end
specify "#parsed_homebrew_version" do specify "#parsed_homebrew_version" do
tab = described_class.new tab = described_class.new
expect(tab.parsed_homebrew_version).to be Version::NULL expect(tab.parsed_homebrew_version).to be Version::NULL
@ -179,7 +171,6 @@ describe Tab do
expect(tab).not_to be_built_as_bottle expect(tab).not_to be_built_as_bottle
expect(tab).to be_poured_from_bottle expect(tab).to be_poured_from_bottle
expect(tab).to be_stable expect(tab).to be_stable
expect(tab).not_to be_devel
expect(tab).not_to be_head expect(tab).not_to be_head
expect(tab.tap.name).to eq("homebrew/core") expect(tab.tap.name).to eq("homebrew/core")
expect(tab.spec).to eq(:stable) expect(tab.spec).to eq(:stable)
@ -189,7 +180,6 @@ describe Tab do
expect(tab.cxxstdlib.type).to eq(:libcxx) expect(tab.cxxstdlib.type).to eq(:libcxx)
expect(tab.runtime_dependencies).to eq(runtime_dependencies) expect(tab.runtime_dependencies).to eq(runtime_dependencies)
expect(tab.stable_version.to_s).to eq("2.14") expect(tab.stable_version.to_s).to eq("2.14")
expect(tab.devel_version.to_s).to eq("2.15")
expect(tab.head_version.to_s).to eq("HEAD-0000000") expect(tab.head_version.to_s).to eq("HEAD-0000000")
expect(tab.source["path"]).to eq(source_path) expect(tab.source["path"]).to eq(source_path)
end end
@ -209,7 +199,6 @@ describe Tab do
expect(tab).not_to be_built_as_bottle expect(tab).not_to be_built_as_bottle
expect(tab).to be_poured_from_bottle expect(tab).to be_poured_from_bottle
expect(tab).to be_stable expect(tab).to be_stable
expect(tab).not_to be_devel
expect(tab).not_to be_head expect(tab).not_to be_head
expect(tab.tap.name).to eq("homebrew/core") expect(tab.tap.name).to eq("homebrew/core")
expect(tab.spec).to eq(:stable) expect(tab.spec).to eq(:stable)
@ -219,7 +208,6 @@ describe Tab do
expect(tab.cxxstdlib.type).to eq(:libcxx) expect(tab.cxxstdlib.type).to eq(:libcxx)
expect(tab.runtime_dependencies).to eq(runtime_dependencies) expect(tab.runtime_dependencies).to eq(runtime_dependencies)
expect(tab.stable_version.to_s).to eq("2.14") expect(tab.stable_version.to_s).to eq("2.14")
expect(tab.devel_version.to_s).to eq("2.15")
expect(tab.head_version.to_s).to eq("HEAD-0000000") expect(tab.head_version.to_s).to eq("HEAD-0000000")
expect(tab.source["path"]).to eq(source_path) expect(tab.source["path"]).to eq(source_path)
end end
@ -233,7 +221,6 @@ describe Tab do
expect(tab).not_to be_built_as_bottle expect(tab).not_to be_built_as_bottle
expect(tab).to be_poured_from_bottle expect(tab).to be_poured_from_bottle
expect(tab).to be_stable expect(tab).to be_stable
expect(tab).not_to be_devel
expect(tab).not_to be_head expect(tab).not_to be_head
expect(tab.tap.name).to eq("homebrew/core") expect(tab.tap.name).to eq("homebrew/core")
expect(tab.spec).to eq(:stable) expect(tab.spec).to eq(:stable)
@ -385,7 +372,6 @@ describe Tab do
expect(tab.stdlib).to eq(subject.stdlib) expect(tab.stdlib).to eq(subject.stdlib)
expect(tab.runtime_dependencies).to eq(subject.runtime_dependencies) expect(tab.runtime_dependencies).to eq(subject.runtime_dependencies)
expect(tab.stable_version).to eq(subject.stable_version) expect(tab.stable_version).to eq(subject.stable_version)
expect(tab.devel_version).to eq(subject.devel_version)
expect(tab.head_version).to eq(subject.head_version) expect(tab.head_version).to eq(subject.head_version)
expect(tab.source["path"]).to eq(subject.source["path"]) expect(tab.source["path"]).to eq(subject.source["path"])
end end

View File

@ -327,8 +327,6 @@ installed formulae or, every 30 days, for all formulae.
Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation. Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation.
* `--include-test`: * `--include-test`:
Install testing dependencies required to run `brew test` *`formula`*. Install testing dependencies required to run `brew test` *`formula`*.
* `--devel`:
If *`formula`* defines it, install the development version.
* `--HEAD`: * `--HEAD`:
If *`formula`* defines it, install the HEAD version, aka. master, trunk, unstable. If *`formula`* defines it, install the HEAD version, aka. master, trunk, unstable.
* `--fetch-HEAD`: * `--fetch-HEAD`:
@ -686,10 +684,6 @@ specify *`formula`* as a required or recommended dependency for their stable bui
Include all formulae that specify *`formula`* as `:optional` type dependency. Include all formulae that specify *`formula`* as `:optional` type dependency.
* `--skip-recommended`: * `--skip-recommended`:
Skip all formulae that specify *`formula`* as `:recommended` type dependency. Skip all formulae that specify *`formula`* as `:recommended` type dependency.
* `--devel`:
Show usage of *`formula`* by development builds.
* `--HEAD`:
Show usage of *`formula`* by HEAD builds.
### `--cache` [*`options`*] [*`formula|cask`*] ### `--cache` [*`options`*] [*`formula|cask`*]

View File

@ -67,7 +67,7 @@ brew install --only-dependencies <formula>
```sh ```sh
$ brew irb $ brew irb
1.8.7 :001 > Formula.factory("ace").methods - Object.methods 1.8.7 :001 > Formula.factory("ace").methods - Object.methods
=> [:install, :path, :homepage, :downloader, :stable, :bottle, :devel, :head, :active_spec, :buildpath, :ensure_specs_set, :url, :version, :specs, :mirrors, :installed?, :explicitly_requested?, :linked_keg, :installed_prefix, :prefix, :rack, :bin, :doc, :include, :info, :lib, :libexec, :man, :man1, :man2, :man3, :man4, :man5, :man6, :man7, :man8, :sbin, :share, :etc, :var, :plist_name, :plist_path, :download_strategy, :cached_download, :caveats, :options, :patches, :keg_only?, :fails_with?, :skip_clean?, :brew, :std_cmake_args, :deps, :external_deps, :recursive_deps, :system, :fetch, :verify_download_integrity, :fails_with_llvm, :fails_with_llvm?, :std_cmake_parameters, :mkdir, :mktemp] => [:install, :path, :homepage, :downloader, :stable, :bottle, :head, :active_spec, :buildpath, :ensure_specs_set, :url, :version, :specs, :mirrors, :installed?, :explicitly_requested?, :linked_keg, :installed_prefix, :prefix, :rack, :bin, :doc, :include, :info, :lib, :libexec, :man, :man1, :man2, :man3, :man4, :man5, :man6, :man7, :man8, :sbin, :share, :etc, :var, :plist_name, :plist_path, :download_strategy, :cached_download, :caveats, :options, :patches, :keg_only?, :fails_with?, :skip_clean?, :brew, :std_cmake_args, :deps, :external_deps, :recursive_deps, :system, :fetch, :verify_download_integrity, :fails_with_llvm, :fails_with_llvm?, :std_cmake_parameters, :mkdir, :mktemp]
1.8.7 :002 > 1.8.7 :002 >
``` ```

View File

@ -484,10 +484,6 @@ Install from a bottle if it exists for the current or newest version of macOS, e
Install testing dependencies required to run \fBbrew test\fR \fIformula\fR\. Install testing dependencies required to run \fBbrew test\fR \fIformula\fR\.
. .
.TP .TP
\fB\-\-devel\fR
If \fIformula\fR defines it, install the development version\.
.
.TP
\fB\-\-HEAD\fR \fB\-\-HEAD\fR
If \fIformula\fR defines it, install the HEAD version, aka\. master, trunk, unstable\. If \fIformula\fR defines it, install the HEAD version, aka\. master, trunk, unstable\.
. .
@ -968,14 +964,6 @@ Include all formulae that specify \fIformula\fR as \fB:optional\fR type dependen
\fB\-\-skip\-recommended\fR \fB\-\-skip\-recommended\fR
Skip all formulae that specify \fIformula\fR as \fB:recommended\fR type dependency\. Skip all formulae that specify \fIformula\fR as \fB:recommended\fR type dependency\.
. .
.TP
\fB\-\-devel\fR
Show usage of \fIformula\fR by development builds\.
.
.TP
\fB\-\-HEAD\fR
Show usage of \fIformula\fR by HEAD builds\.
.
.SS "\fB\-\-cache\fR [\fIoptions\fR] [\fIformula|cask\fR]" .SS "\fB\-\-cache\fR [\fIoptions\fR] [\fIformula|cask\fR]"
Display Homebrew\'s download cache\. See also \fBHOMEBREW_CACHE\fR\. Display Homebrew\'s download cache\. See also \fBHOMEBREW_CACHE\fR\.
. .