From ecbe2213e4ee19bb1b2ce434a7f9f0a2e56fa4dc Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Wed, 12 Aug 2020 21:08:14 +0000 Subject: [PATCH 01/33] brew.sh: handle systems with no 'locale' such as Alpine Linux Closes Linuxbrew/docker#83 --- Library/Homebrew/brew.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index b958c9e1ab..a04c3e2ba6 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -6,7 +6,10 @@ case "$HOMEBREW_SYSTEM" in esac # Force UTF-8 to avoid encoding issues for users with broken locale settings. -if [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] +if ! which locale &>/dev/null +then + export LC_ALL=C +elif [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] then if [[ -n "$HOMEBREW_MACOS" ]] then From bab43d4cc8b828736a91565e5787dbbc5064ea7c Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 13 Aug 2020 06:59:39 -0500 Subject: [PATCH 02/33] brew.sh: use 'command -v' instead of 'which' Co-authored-by: Shaun Jackman --- Library/Homebrew/brew.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index a04c3e2ba6..9af5397792 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -6,7 +6,7 @@ case "$HOMEBREW_SYSTEM" in esac # Force UTF-8 to avoid encoding issues for users with broken locale settings. -if ! which locale &>/dev/null +if ! command -v locale >/dev/null then export LC_ALL=C elif [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] From d33691dcdb6f986dd970265d0018b4ecaa16f0b9 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 13 Aug 2020 17:08:06 -0500 Subject: [PATCH 03/33] brew.sh: don't suppress stderr for 'locale charmap' Co-authored-by: Shaun Jackman --- Library/Homebrew/brew.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 9af5397792..f985c3b7aa 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -9,7 +9,7 @@ esac if ! command -v locale >/dev/null then export LC_ALL=C -elif [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] +elif [[ "$(locale charmap)" != "UTF-8" ]] then if [[ -n "$HOMEBREW_MACOS" ]] then From b5363025a675d0b8f661333a87b31a817a79301d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 14 Aug 2020 02:26:29 +0200 Subject: [PATCH 04/33] Refactor and document `BuildEnvironment`. --- Library/Homebrew/build_environment.rb | 41 ++++++++++++++------------- Library/Homebrew/cmd/--env.rb | 4 +-- Library/Homebrew/exceptions.rb | 2 +- Library/Homebrew/formula.rb | 2 +- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Library/Homebrew/build_environment.rb b/Library/Homebrew/build_environment.rb index ad0508d22a..ed6f319730 100644 --- a/Library/Homebrew/build_environment.rb +++ b/Library/Homebrew/build_environment.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +# Settings for the build environment. +# +# @api private class BuildEnvironment def initialize(*settings) @settings = Set.new(*settings) @@ -23,35 +26,35 @@ class BuildEnvironment @settings.include? :userpaths end + # DSL for specifying build environment settings. module DSL def env(*settings) @env ||= BuildEnvironment.new @env.merge(settings) end end -end -module Homebrew - module_function + KEYS = %w[ + CC CXX LD OBJC OBJCXX + HOMEBREW_CC HOMEBREW_CXX + CFLAGS CXXFLAGS CPPFLAGS LDFLAGS SDKROOT MAKEFLAGS + CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_LIBRARY_PATH CMAKE_FRAMEWORK_PATH + MACOSX_DEPLOYMENT_TARGET PKG_CONFIG_PATH PKG_CONFIG_LIBDIR + HOMEBREW_DEBUG HOMEBREW_MAKE_JOBS HOMEBREW_VERBOSE + HOMEBREW_SVN HOMEBREW_GIT + HOMEBREW_SDKROOT + MAKE GIT CPP + ACLOCAL_PATH PATH CPATH + LD_LIBRARY_PATH LD_RUN_PATH LD_PRELOAD LIBRARY_PATH + ].freeze + private_constant :KEYS - def build_env_keys(env) - %w[ - CC CXX LD OBJC OBJCXX - HOMEBREW_CC HOMEBREW_CXX - CFLAGS CXXFLAGS CPPFLAGS LDFLAGS SDKROOT MAKEFLAGS - CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_LIBRARY_PATH CMAKE_FRAMEWORK_PATH - MACOSX_DEPLOYMENT_TARGET PKG_CONFIG_PATH PKG_CONFIG_LIBDIR - HOMEBREW_DEBUG HOMEBREW_MAKE_JOBS HOMEBREW_VERBOSE - HOMEBREW_SVN HOMEBREW_GIT - HOMEBREW_SDKROOT - MAKE GIT CPP - ACLOCAL_PATH PATH CPATH - LD_LIBRARY_PATH LD_RUN_PATH LD_PRELOAD LIBRARY_PATH - ].select { |key| env.key?(key) } + def self.keys(env) + KEYS & env.keys end - def dump_build_env(env, f = $stdout) - keys = build_env_keys(env) + def self.dump(env, f = $stdout) + keys = self.keys(env) keys -= %w[CC CXX OBJC OBJCXX] if env["CC"] == env["HOMEBREW_CC"] keys.each do |key| diff --git a/Library/Homebrew/cmd/--env.rb b/Library/Homebrew/cmd/--env.rb index 7586631754..80319d3053 100644 --- a/Library/Homebrew/cmd/--env.rb +++ b/Library/Homebrew/cmd/--env.rb @@ -43,9 +43,9 @@ module Homebrew Utils::Shell.from_path(args.shell) end - env_keys = build_env_keys(ENV) + env_keys = BuildEnvironment.keys(ENV) if shell.nil? - dump_build_env ENV + BuildEnvironment.dump ENV else env_keys.each do |key| puts Utils::Shell.export_value(key, ENV[key], shell) diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index f3fb93c6f0..7c6c862ad8 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -369,7 +369,7 @@ class BuildError < RuntimeError ohai "Configuration" SystemConfig.dump_verbose_config ohai "ENV" - Homebrew.dump_build_env(env) + BuildEnvironment.dump env puts onoe "#{formula.full_name} #{formula.version} did not build" unless (logs = Dir["#{formula.logs}/*"]).empty? diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 5849baaa20..ddc6ec671a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2020,7 +2020,7 @@ class Formula SystemConfig.dump_verbose_config(log) log.puts - Homebrew.dump_build_env(env, log) + BuildEnvironment.dump env, log raise BuildError.new(self, cmd, args, env) end From d50dc2e1bb35160600d285f859f2546470162780 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 14 Aug 2020 04:33:33 +0200 Subject: [PATCH 05/33] Refactor and document `Homebrew::Diagnostic`. --- Library/Homebrew/diagnostic.rb | 42 ++------------------ Library/Homebrew/extend/os/mac/diagnostic.rb | 38 ++++++++++++++++++ 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 82a511d193..e8309f30d1 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -12,6 +12,9 @@ require "cask/caskroom" require "cask/quarantine" module Homebrew + # Module containing diagnostic checks. + # + # @api private module Diagnostic def self.missing_deps(ff, hide = nil) missing = {} @@ -25,44 +28,7 @@ module Homebrew missing end - class Volumes - def initialize - @volumes = get_mounts - end - - def which(path) - vols = get_mounts path - - # no volume found - return -1 if vols.empty? - - vol_index = @volumes.index(vols[0]) - # volume not found in volume list - return -1 if vol_index.nil? - - vol_index - end - - def get_mounts(path = nil) - vols = [] - # get the volume of path, if path is nil returns all volumes - - args = %w[/bin/df -P] - args << path if path - - Utils.popen_read(*args) do |io| - io.each_line do |line| - case line.chomp - # regex matches: /dev/disk0s2 489562928 440803616 48247312 91% / - when /^.+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[0-9]{1,3}%\s+(.+)/ - vols << Regexp.last_match(1) - end - end - end - vols - end - end - + # Diagnostic checks. class Checks def initialize(verbose = true) @verbose = verbose diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index d9b9cadf32..21cd0faee4 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -2,6 +2,44 @@ module Homebrew module Diagnostic + class Volumes + def initialize + @volumes = get_mounts + end + + def which(path) + vols = get_mounts path + + # no volume found + return -1 if vols.empty? + + vol_index = @volumes.index(vols[0]) + # volume not found in volume list + return -1 if vol_index.nil? + + vol_index + end + + def get_mounts(path = nil) + vols = [] + # get the volume of path, if path is nil returns all volumes + + args = %w[/bin/df -P] + args << path if path + + Utils.popen_read(*args) do |io| + io.each_line do |line| + case line.chomp + # regex matches: /dev/disk0s2 489562928 440803616 48247312 91% / + when /^.+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[0-9]{1,3}%\s+(.+)/ + vols << Regexp.last_match(1) + end + end + end + vols + end + end + class Checks undef fatal_build_from_source_checks, supported_configuration_checks, build_from_source_checks From 4eff378d09563b6ce8612f480cb7f5f51fb818b5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 14 Aug 2020 03:39:31 +0200 Subject: [PATCH 06/33] Refactor and document `CxxStdlib`. --- Library/Homebrew/cxxstdlib.rb | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb index 1b279c28b9..e2754c51b7 100644 --- a/Library/Homebrew/cxxstdlib.rb +++ b/Library/Homebrew/cxxstdlib.rb @@ -2,9 +2,11 @@ require "compilers" +# Combination of C++ standard library and compiler. class CxxStdlib include CompilerConstants + # Error for when a formula's dependency was built with a different C++ standard library. class CompatibilityError < StandardError def initialize(formula, dep, stdlib) super <<~EOS @@ -17,8 +19,8 @@ class CxxStdlib def self.create(type, compiler) raise ArgumentError, "Invalid C++ stdlib type: #{type}" if type && ![:libstdcxx, :libcxx].include?(type) - klass = (compiler.to_s =~ GNU_GCC_REGEXP) ? GnuStdlib : AppleStdlib - klass.new(type, compiler) + apple_compiler = compiler.to_s.match?(GNU_GCC_REGEXP) ? false : true + CxxStdlib.new(type, compiler, apple_compiler) end def self.check_compatibility(formula, deps, keg, compiler) @@ -35,9 +37,10 @@ class CxxStdlib attr_reader :type, :compiler - def initialize(type, compiler) + def initialize(type, compiler, apple_compiler) @type = type @compiler = compiler.to_sym + @apple_compiler = apple_compiler end # If either package doesn't use C++, all is well. @@ -72,15 +75,7 @@ class CxxStdlib "#<#{self.class.name}: #{compiler} #{type}>" end - class AppleStdlib < CxxStdlib - def apple_compiler? - true - end - end - - class GnuStdlib < CxxStdlib - def apple_compiler? - false - end + def apple_compiler? + @apple_compiler end end From 13bc69385c0516823a08318bbb68a20c39ba9e8e Mon Sep 17 00:00:00 2001 From: William Ma Date: Thu, 13 Aug 2020 08:55:55 -0400 Subject: [PATCH 07/33] args: Move named args parsing to separate class --- Library/Homebrew/cli/args.rb | 159 ++++----------------------- Library/Homebrew/cli/named_args.rb | 168 +++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+), 141 deletions(-) create mode 100644 Library/Homebrew/cli/named_args.rb diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index a67d0e7d10..84c621fd8b 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require "cli/named_args" require "ostruct" module Homebrew @@ -19,7 +20,7 @@ module Homebrew # Can set these because they will be overwritten by freeze_named_args! # (whereas other values below will only be overwritten if passed). - self[:named_args] = [] + self[:named_args] = NamedArgs.new self[:remaining] = [] end @@ -28,18 +29,12 @@ module Homebrew end def freeze_named_args!(named_args) - # Reset cache values reliant on named_args - @formulae = nil - @formulae_and_casks = nil - @resolved_formulae = nil - @resolved_formulae_casks = nil - @formulae_paths = nil - @casks = nil - @loaded_casks = nil - @kegs = nil - @kegs_casks = nil - - self[:named_args] = named_args.freeze + self[:named_args] = NamedArgs.new( + *named_args.freeze, + override_spec: spec(nil), + force_bottle: force_bottle?, + flags: flags_only, + ) end def freeze_processed_options!(processed_options) @@ -54,7 +49,7 @@ module Homebrew end def named - named_args || [] + named_args || NamedArgs.new end def no_named? @@ -62,102 +57,39 @@ module Homebrew end def formulae - require "formula" - - @formulae ||= (downcased_unique_named - casks).map do |name| - Formulary.factory(name, spec, force_bottle: force_bottle?, flags: flags_only) - end.uniq(&:name).freeze + named.to_formulae end def formulae_and_casks - @formulae_and_casks ||= begin - formulae_and_casks = [] - - downcased_unique_named.each do |name| - formulae_and_casks << Formulary.factory(name, spec) - rescue FormulaUnavailableError - begin - formulae_and_casks << Cask::CaskLoader.load(name) - rescue Cask::CaskUnavailableError - raise "No available formula or cask with the name \"#{name}\"" - end - end - - formulae_and_casks.freeze - end + named.to_formulae_and_casks end def resolved_formulae - require "formula" - - @resolved_formulae ||= (downcased_unique_named - casks).map do |name| - Formulary.resolve(name, spec: spec(nil), force_bottle: force_bottle?, flags: flags_only) - end.uniq(&:name).freeze + named.to_resolved_formulae end def resolved_formulae_casks - @resolved_formulae_casks ||= begin - resolved_formulae = [] - casks = [] - - downcased_unique_named.each do |name| - resolved_formulae << Formulary.resolve(name, spec: spec(nil), - force_bottle: force_bottle?, flags: flags_only) - rescue FormulaUnavailableError - begin - casks << Cask::CaskLoader.load(name) - rescue Cask::CaskUnavailableError - raise "No available formula or cask with the name \"#{name}\"" - end - end - - [resolved_formulae.freeze, casks.freeze].freeze - end + named.to_resolved_formulae_to_casks end def formulae_paths - @formulae_paths ||= (downcased_unique_named - casks).map do |name| - Formulary.path(name) - end.uniq.freeze + named.to_formulae_paths end def casks - @casks ||= downcased_unique_named.grep(HOMEBREW_CASK_TAP_CASK_REGEX) - .freeze + named.homebrew_tap_cask_names end def loaded_casks - @loaded_casks ||= downcased_unique_named.map(&Cask::CaskLoader.method(:load)).freeze + named.to_casks end def kegs - @kegs ||= downcased_unique_named.map do |name| - resolve_keg name - rescue NoSuchKegError => e - if (reason = Homebrew::MissingFormula.suggest_command(name, "uninstall")) - $stderr.puts reason - end - raise e - end.freeze + named.to_kegs end def kegs_casks - @kegs_casks ||= begin - kegs = [] - casks = [] - - downcased_unique_named.each do |name| - kegs << resolve_keg(name) - rescue NoSuchKegError - begin - casks << Cask::CaskLoader.load(name) - rescue Cask::CaskUnavailableError - raise "No installed keg or cask with the name \"#{name}\"" - end - end - - [kegs.freeze, casks.freeze].freeze - end + named.to_kegs_to_casks end def build_stable? @@ -218,17 +150,6 @@ module Homebrew @cli_args.freeze end - def downcased_unique_named - # Only lowercase names, not paths, bottle filenames or URLs - named.map do |arg| - if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg) - arg - else - arg.downcase - end - end.uniq - end - def spec(default = :stable) if HEAD? :head @@ -238,50 +159,6 @@ module Homebrew default end end - - def resolve_keg(name) - require "keg" - require "formula" - require "missing_formula" - - raise UsageError if name.blank? - - rack = Formulary.to_rack(name.downcase) - - dirs = rack.directory? ? rack.subdirs : [] - raise NoSuchKegError, rack.basename if dirs.empty? - - linked_keg_ref = HOMEBREW_LINKED_KEGS/rack.basename - opt_prefix = HOMEBREW_PREFIX/"opt/#{rack.basename}" - - begin - if opt_prefix.symlink? && opt_prefix.directory? - Keg.new(opt_prefix.resolved_path) - elsif linked_keg_ref.symlink? && linked_keg_ref.directory? - Keg.new(linked_keg_ref.resolved_path) - elsif dirs.length == 1 - Keg.new(dirs.first) - else - f = if name.include?("/") || File.exist?(name) - Formulary.factory(name) - else - Formulary.from_rack(rack) - end - - unless (prefix = f.installed_prefix).directory? - raise MultipleVersionsInstalledError, "#{rack.basename} has multiple installed versions" - end - - Keg.new(prefix) - end - rescue FormulaUnavailableError - raise MultipleVersionsInstalledError, <<~EOS - Multiple kegs installed to #{rack} - However we don't know which one you refer to. - Please delete (with rm -rf!) all but one and then try again. - EOS - end - end end end end diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb new file mode 100644 index 0000000000..0690bfb2f8 --- /dev/null +++ b/Library/Homebrew/cli/named_args.rb @@ -0,0 +1,168 @@ +# frozen_string_literal: true + +require "delegate" + +module Homebrew + module CLI + class NamedArgs < SimpleDelegator + def initialize(*args, override_spec: nil, force_bottle: false, flags: []) + @args = args + @override_spec = override_spec + @force_bottle = force_bottle + @flags = flags + + __setobj__(@args) + end + + def to_formulae + @to_formulae ||= (downcased_unique_named - homebrew_tap_cask_names).map do |name| + Formulary.factory(name, spec, force_bottle: @force_bottle, flags: @flags) + end.uniq(&:name).freeze + end + + def to_formulae_and_casks + @to_formulae_and_casks ||= begin + formulae_and_casks = [] + + downcased_unique_named.each do |name| + formulae_and_casks << Formulary.factory(name, spec) + rescue FormulaUnavailableError + begin + formulae_and_casks << Cask::CaskLoader.load(name) + rescue Cask::CaskUnavailableError + raise "No available formula or cask with the name \"#{name}\"" + end + end + + formulae_and_casks.freeze + end + end + + def to_resolved_formulae + @to_resolved_formulae ||= (downcased_unique_named - homebrew_tap_cask_names).map do |name| + Formulary.resolve(name, spec: spec(nil), force_bottle: @force_bottle, flags: @flags) + end.uniq(&:name).freeze + end + + def to_resolved_formulae_to_casks + @to_resolved_formulae_to_casks ||= begin + resolved_formulae = [] + casks = [] + + downcased_unique_named.each do |name| + resolved_formulae << Formulary.resolve(name, spec: spec(nil), force_bottle: @force_bottle, flags: @flags) + rescue FormulaUnavailableError + begin + casks << Cask::CaskLoader.load(name) + rescue Cask::CaskUnavailableError + raise "No available formula or cask with the name \"#{name}\"" + end + end + + [resolved_formulae.freeze, casks.freeze].freeze + end + end + + def to_formulae_paths + @to_formulae_paths ||= (downcased_unique_named - homebrew_tap_cask_names).map do |name| + Formulary.path(name) + end.uniq.freeze + end + + def to_casks + @to_casks ||= downcased_unique_named.map(&Cask::CaskLoader.method(:load)).freeze + end + + def to_kegs + @to_kegs ||= downcased_unique_named.map do |name| + resolve_keg name + rescue NoSuchKegError => e + if (reason = Homebrew::MissingFormula.suggest_command(name, "uninstall")) + $stderr.puts reason + end + raise e + end.freeze + end + + def to_kegs_to_casks + @to_kegs_to_casks ||= begin + kegs = [] + casks = [] + + downcased_unique_named.each do |name| + kegs << resolve_keg(name) + rescue NoSuchKegError, FormulaUnavailableError + begin + casks << Cask::CaskLoader.load(name) + rescue Cask::CaskUnavailableError + raise "No installed keg or cask with the name \"#{name}\"" + end + end + + [kegs.freeze, casks.freeze].freeze + end + end + + def homebrew_tap_cask_names + downcased_unique_named.grep(HOMEBREW_CASK_TAP_CASK_REGEX) + end + + private + + def downcased_unique_named + # Only lowercase names, not paths, bottle filenames or URLs + map do |arg| + if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg) + arg + else + arg.downcase + end + end.uniq + end + + def spec(default = :stable) + @override_spec || default + end + + def resolve_keg(name) + raise UsageError if name.blank? + + rack = Formulary.to_rack(name.downcase) + + dirs = rack.directory? ? rack.subdirs : [] + raise NoSuchKegError, rack.basename if dirs.empty? + + linked_keg_ref = HOMEBREW_LINKED_KEGS/rack.basename + opt_prefix = HOMEBREW_PREFIX/"opt/#{rack.basename}" + + begin + if opt_prefix.symlink? && opt_prefix.directory? + Keg.new(opt_prefix.resolved_path) + elsif linked_keg_ref.symlink? && linked_keg_ref.directory? + Keg.new(linked_keg_ref.resolved_path) + elsif dirs.length == 1 + Keg.new(dirs.first) + else + f = if name.include?("/") || File.exist?(name) + Formulary.factory(name) + else + Formulary.from_rack(rack) + end + + unless (prefix = f.installed_prefix).directory? + raise MultipleVersionsInstalledError, "#{rack.basename} has multiple installed versions" + end + + Keg.new(prefix) + end + rescue FormulaUnavailableError + raise MultipleVersionsInstalledError, <<~EOS + Multiple kegs installed to #{rack} + However we don't know which one you refer to. + Please delete (with rm -rf!) all but one and then try again. + EOS + end + end + end + end +end From c8016f6c0af91ed5a105ea82911259a7bff03666 Mon Sep 17 00:00:00 2001 From: William Ma Date: Fri, 14 Aug 2020 13:48:03 -0400 Subject: [PATCH 08/33] named args: add method tests --- Library/Homebrew/test/cli/named_args_spec.rb | 112 +++++++++++++++++++ Library/Homebrew/test/spec_helper.rb | 2 + Library/Homebrew/test/support/helper/cask.rb | 14 +++ 3 files changed, 128 insertions(+) create mode 100644 Library/Homebrew/test/cli/named_args_spec.rb create mode 100644 Library/Homebrew/test/support/helper/cask.rb diff --git a/Library/Homebrew/test/cli/named_args_spec.rb b/Library/Homebrew/test/cli/named_args_spec.rb new file mode 100644 index 0000000000..c3bc0f6e62 --- /dev/null +++ b/Library/Homebrew/test/cli/named_args_spec.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true + +require "cli/named_args" + +describe Homebrew::CLI::NamedArgs do + let(:foo) do + formula "foo" do + url "https://brew.sh" + version "1.0" + end + end + + let(:foo_keg) do + path = (HOMEBREW_CELLAR/"foo/1.0").resolved_path + mkdir_p path + Keg.new(path) + end + + let(:bar) do + formula "bar" do + url "https://brew.sh" + version "1.0" + end + end + + let(:bar_keg) do + path = (HOMEBREW_CELLAR/"bar/1.0").resolved_path + mkdir_p path + Keg.new(path) + end + + let(:baz) do + Cask::CaskLoader.load(+<<~RUBY) + cask "baz" do + version "1.0" + end + RUBY + end + + describe "#to_formulae" do + it "returns formulae" do + allow(Formulary).to receive(:loader_for).and_call_original + stub_formula_loader foo + stub_formula_loader bar + + expect(described_class.new("foo", "bar").to_formulae).to eq [foo, bar] + end + end + + describe "#to_formulae_and_casks" do + it "returns formulae and casks" do + allow(Formulary).to receive(:loader_for).and_call_original + stub_formula_loader foo + stub_cask_loader baz + + expect(described_class.new("foo", "baz").to_formulae_and_casks).to eq [foo, baz] + end + end + + describe "#to_resolved_formulae" do + it "returns resolved formulae" do + allow(Formulary).to receive(:resolve).and_return(foo, bar) + + expect(described_class.new("foo", "bar").to_resolved_formulae).to eq [foo, bar] + end + end + + describe "#to_resolved_formulae_to_casks" do + it "returns resolved formulae, as well as casks" do + allow(Formulary).to receive(:resolve).and_call_original + allow(Formulary).to receive(:resolve).with("foo", any_args).and_return foo + stub_cask_loader baz + + resolved_formulae, casks = described_class.new("foo", "baz").to_resolved_formulae_to_casks + + expect(resolved_formulae).to eq [foo] + expect(casks).to eq [baz] + end + end + + describe "#to_casks" do + it "returns casks" do + stub_cask_loader baz + + expect(described_class.new("baz").to_casks).to eq [baz] + end + end + + describe "#to_kegs" do + it "returns kegs" do + named_args = described_class.new("foo", "bar") + allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg + allow(named_args).to receive(:resolve_keg).with("bar").and_return bar_keg + + expect(named_args.to_kegs).to eq [foo_keg, bar_keg] + end + end + + describe "#to_kegs_to_casks" do + it "returns kegs, as well as casks" do + named_args = described_class.new("foo", "baz") + allow(named_args).to receive(:resolve_keg).and_call_original + allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg + stub_cask_loader baz + + kegs, casks = named_args.to_kegs_to_casks + + expect(kegs).to eq [foo_keg] + expect(casks).to eq [baz] + end + end +end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 9e6ee3e826..1aad194f5e 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -36,6 +36,7 @@ $LOAD_PATH.push(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/suppo require_relative "../global" require "test/support/no_seed_progress_formatter" +require "test/support/helper/cask" require "test/support/helper/fixtures" require "test/support/helper/formula" require "test/support/helper/mktmpdir" @@ -86,6 +87,7 @@ RSpec.configure do |config| config.include(RuboCop::RSpec::ExpectOffense) + config.include(Test::Helper::Cask) config.include(Test::Helper::Fixtures) config.include(Test::Helper::Formula) config.include(Test::Helper::MkTmpDir) diff --git a/Library/Homebrew/test/support/helper/cask.rb b/Library/Homebrew/test/support/helper/cask.rb new file mode 100644 index 0000000000..875d9ac8a9 --- /dev/null +++ b/Library/Homebrew/test/support/helper/cask.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "cask/cask_loader" + +module Test + module Helper + module Cask + def stub_cask_loader(cask, ref = cask.token) + loader = ::Cask::CaskLoader::FromInstanceLoader.new cask + allow(::Cask::CaskLoader).to receive(:for).with(ref).and_return(loader) + end + end + end +end From 01dec9c6a8d7cde25f0a2351e206a8628b669eee Mon Sep 17 00:00:00 2001 From: Seeker Date: Sun, 16 Aug 2020 10:28:26 -0700 Subject: [PATCH 09/33] utils/inreplace: add `inreplace_pairs` --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 33 +++------------------ Library/Homebrew/test/inreplace_spec.rb | 8 +++++ Library/Homebrew/utils/inreplace.rb | 21 ++++++++++++- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 8ed387f7de..5cdd52714a 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -294,7 +294,10 @@ module Homebrew "", ] end - new_contents = inreplace_pairs(formula.path, replacement_pairs.uniq.compact, args: args) + new_contents = Utils::Inreplace.inreplace_pairs(formula.path, + replacement_pairs.uniq.compact, + read_only_run: read_only_run, + silent: args.quiet?) new_formula_version = formula_version(formula, requested_spec, new_contents) @@ -462,34 +465,6 @@ module Homebrew [remote_url, username] end - def inreplace_pairs(path, replacement_pairs, args:) - read_only_run = args.dry_run? && !args.write? - if read_only_run - str = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read } - contents = StringInreplaceExtension.new(str) - replacement_pairs.each do |old, new| - ohai "replace #{old.inspect} with #{new.inspect}" unless args.quiet? - raise "No old value for new value #{new}! Did you pass the wrong arguments?" unless old - - contents.gsub!(old, new) - end - raise Utils::InreplaceError, path => contents.errors unless contents.errors.empty? - - path.atomic_write(contents.inreplace_string) if args.write? - contents.inreplace_string - else - Utils::Inreplace.inreplace(path) do |s| - replacement_pairs.each do |old, new| - ohai "replace #{old.inspect} with #{new.inspect}" unless args.quiet? - raise "No old value for new value #{new}! Did you pass the wrong arguments?" unless old - - s.gsub!(old, new) - end - end - path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read } - end - end - def formula_version(formula, spec, contents = nil) name = formula.name path = formula.path diff --git a/Library/Homebrew/test/inreplace_spec.rb b/Library/Homebrew/test/inreplace_spec.rb index e35e5bd3ae..8b2aa1be17 100644 --- a/Library/Homebrew/test/inreplace_spec.rb +++ b/Library/Homebrew/test/inreplace_spec.rb @@ -305,4 +305,12 @@ describe Utils::Inreplace do end }.to raise_error(Utils::InreplaceError) end + + describe "#inreplace_pairs" do + it "raises error if there is no old value" do + expect { + described_class.inreplace_pairs(file.path, [[nil, "f"]]) + }.to raise_error(Utils::InreplaceError) + end + end end diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index bf0aeb7add..fb3f355bf5 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -11,6 +11,8 @@ module Utils end module Inreplace + module_function + # Sometimes we have to change a bit before we install. Mostly we # prefer a patch but if you need the `prefix` of this formula in the # patch you have to resort to `inreplace`, because in the patch @@ -42,6 +44,23 @@ module Utils raise InreplaceError, errors unless errors.empty? end - module_function :inreplace + + def inreplace_pairs(path, replacement_pairs, read_only_run: false, silent: false) + str = File.open(path, "rb", &:read) + contents = StringInreplaceExtension.new(str) + replacement_pairs.each do |old, new| + ohai "replace #{old.inspect} with #{new.inspect}" unless silent + unless old + contents.errors << "No old value for new value #{new}! Did you pass the wrong arguments?" + next + end + + contents.gsub!(old, new) + end + raise InreplaceError, path => contents.errors unless contents.errors.empty? + + Pathname(path).atomic_write(contents.inreplace_string) unless read_only_run + contents.inreplace_string + end end end From 48984953892a83f4dcd2c2c88a72930e547693d4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2020 10:26:50 +0000 Subject: [PATCH 10/33] build(deps): bump rubocop-rspec in /Library/Homebrew Bumps [rubocop-rspec](https://github.com/rubocop-hq/rubocop-rspec) from 1.42.0 to 1.43.1. - [Release notes](https://github.com/rubocop-hq/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop-hq/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop-rspec/compare/v1.42.0...v1.43.1) Signed-off-by: dependabot-preview[bot] --- Library/Homebrew/Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 6ac6cff31a..97a001e83a 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -112,8 +112,8 @@ GEM parser (>= 2.7.1.4) rubocop-performance (1.7.1) rubocop (>= 0.82.0) - rubocop-rspec (1.42.0) - rubocop (>= 0.87.0) + rubocop-rspec (1.43.1) + rubocop (~> 0.87) ruby-macho (2.2.0) ruby-progressbar (1.10.1) simplecov (0.18.5) From bd2724fa18e9207cffa1ec3ec5e68bfe3edead7a Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Mon, 17 Aug 2020 13:31:16 +0100 Subject: [PATCH 11/33] debrew: fix irb start --- Library/Homebrew/debrew/irb.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/debrew/irb.rb b/Library/Homebrew/debrew/irb.rb index 4d2f79734d..e37d35b92c 100644 --- a/Library/Homebrew/debrew/irb.rb +++ b/Library/Homebrew/debrew/irb.rb @@ -11,7 +11,7 @@ module IRB def start_within(binding) unless @setup_done - setup(nil) + setup(nil, argv: []) @setup_done = true end From 90cf01e245acf92ff135e9452461db9512cf475e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 17 Aug 2020 16:13:28 +0100 Subject: [PATCH 12/33] os/linux: add no-op MacOS.sdk_path method. Fixes https://github.com/Homebrew/linuxbrew-core/issues/20938 --- Library/Homebrew/os/linux.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/os/linux.rb b/Library/Homebrew/os/linux.rb index 2cffb06535..da4b9d7acd 100644 --- a/Library/Homebrew/os/linux.rb +++ b/Library/Homebrew/os/linux.rb @@ -57,6 +57,10 @@ module OS nil end + def sdk_path + nil + end + module Xcode module_function From b8d21dcf6008dafa4e9e9c2e1c56e5e1c057e1d2 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 17 Aug 2020 15:24:18 +0000 Subject: [PATCH 13/33] brew.sh: handle Linux systems with no 'locale' --- Library/Homebrew/brew.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index f985c3b7aa..59616772a1 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -6,15 +6,18 @@ case "$HOMEBREW_SYSTEM" in esac # Force UTF-8 to avoid encoding issues for users with broken locale settings. -if ! command -v locale >/dev/null +if [[ -n "$HOMEBREW_MACOS" ]] then - export LC_ALL=C -elif [[ "$(locale charmap)" != "UTF-8" ]] -then - if [[ -n "$HOMEBREW_MACOS" ]] + if [[ "$(locale charmap)" != "UTF-8" ]] then export LC_ALL="en_US.UTF-8" - else + fi +else + if ! command -v locale >/dev/null + then + export LC_ALL=C + elif [[ "$(locale charmap)" != "UTF-8" ]] + then locales=$(locale -a) c_utf_regex='\bC\.(utf8|UTF-8)\b' en_us_regex='\ben_US\.(utf8|UTF-8)\b' From a7b063efb501c6ae4f6c02f12062c4af41e63806 Mon Sep 17 00:00:00 2001 From: William Ma Date: Mon, 17 Aug 2020 12:40:23 -0400 Subject: [PATCH 14/33] named_args: Warn when cask with same name exists --- Library/Homebrew/cli/named_args.rb | 12 ++++++++++++ Library/Homebrew/test/cli/named_args_spec.rb | 13 ++++++------- Library/Homebrew/test/support/helper/cask.rb | 4 +++- Library/Homebrew/test/support/helper/formula.rb | 4 +++- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb index 0690bfb2f8..67aa1271ad 100644 --- a/Library/Homebrew/cli/named_args.rb +++ b/Library/Homebrew/cli/named_args.rb @@ -26,6 +26,8 @@ module Homebrew downcased_unique_named.each do |name| formulae_and_casks << Formulary.factory(name, spec) + + puts "Treating #{name} as a formula. For the cask, use homebrew/cask/#{name}" if cask_exists_with_ref name rescue FormulaUnavailableError begin formulae_and_casks << Cask::CaskLoader.load(name) @@ -51,6 +53,8 @@ module Homebrew downcased_unique_named.each do |name| resolved_formulae << Formulary.resolve(name, spec: spec(nil), force_bottle: @force_bottle, flags: @flags) + + puts "Treating #{name} as a formula. For the cask, use homebrew/cask/#{name}" if cask_exists_with_ref name rescue FormulaUnavailableError begin casks << Cask::CaskLoader.load(name) @@ -91,6 +95,8 @@ module Homebrew downcased_unique_named.each do |name| kegs << resolve_keg(name) + + puts "Treating #{name} as a keg. For the cask, use homebrew/cask/#{name}" if cask_exists_with_ref name rescue NoSuchKegError, FormulaUnavailableError begin casks << Cask::CaskLoader.load(name) @@ -163,6 +169,12 @@ module Homebrew EOS end end + + def cask_exists_with_ref(ref) + Cask::CaskLoader.load ref + rescue Cask::CaskUnavailableError + false + end end end end diff --git a/Library/Homebrew/test/cli/named_args_spec.rb b/Library/Homebrew/test/cli/named_args_spec.rb index c3bc0f6e62..cccce6dc95 100644 --- a/Library/Homebrew/test/cli/named_args_spec.rb +++ b/Library/Homebrew/test/cli/named_args_spec.rb @@ -39,8 +39,7 @@ describe Homebrew::CLI::NamedArgs do describe "#to_formulae" do it "returns formulae" do - allow(Formulary).to receive(:loader_for).and_call_original - stub_formula_loader foo + stub_formula_loader foo, call_original: true stub_formula_loader bar expect(described_class.new("foo", "bar").to_formulae).to eq [foo, bar] @@ -49,9 +48,8 @@ describe Homebrew::CLI::NamedArgs do describe "#to_formulae_and_casks" do it "returns formulae and casks" do - allow(Formulary).to receive(:loader_for).and_call_original - stub_formula_loader foo - stub_cask_loader baz + stub_formula_loader foo, call_original: true + stub_cask_loader baz, call_original: true expect(described_class.new("foo", "baz").to_formulae_and_casks).to eq [foo, baz] end @@ -69,7 +67,7 @@ describe Homebrew::CLI::NamedArgs do it "returns resolved formulae, as well as casks" do allow(Formulary).to receive(:resolve).and_call_original allow(Formulary).to receive(:resolve).with("foo", any_args).and_return foo - stub_cask_loader baz + stub_cask_loader baz, call_original: true resolved_formulae, casks = described_class.new("foo", "baz").to_resolved_formulae_to_casks @@ -101,7 +99,8 @@ describe Homebrew::CLI::NamedArgs do named_args = described_class.new("foo", "baz") allow(named_args).to receive(:resolve_keg).and_call_original allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg - stub_cask_loader baz + + stub_cask_loader baz, call_original: true kegs, casks = named_args.to_kegs_to_casks diff --git a/Library/Homebrew/test/support/helper/cask.rb b/Library/Homebrew/test/support/helper/cask.rb index 875d9ac8a9..940e80a4f9 100644 --- a/Library/Homebrew/test/support/helper/cask.rb +++ b/Library/Homebrew/test/support/helper/cask.rb @@ -5,7 +5,9 @@ require "cask/cask_loader" module Test module Helper module Cask - def stub_cask_loader(cask, ref = cask.token) + def stub_cask_loader(cask, ref = cask.token, call_original: false) + allow(::Cask::CaskLoader).to receive(:for).and_call_original if call_original + loader = ::Cask::CaskLoader::FromInstanceLoader.new cask allow(::Cask::CaskLoader).to receive(:for).with(ref).and_return(loader) end diff --git a/Library/Homebrew/test/support/helper/formula.rb b/Library/Homebrew/test/support/helper/formula.rb index 36fe7f2807..caf4a1c73a 100644 --- a/Library/Homebrew/test/support/helper/formula.rb +++ b/Library/Homebrew/test/support/helper/formula.rb @@ -11,7 +11,9 @@ module Test # Use a stubbed {Formulary::FormulaLoader} to make a given formula be found # when loading from {Formulary} with `ref`. - def stub_formula_loader(formula, ref = formula.full_name) + def stub_formula_loader(formula, ref = formula.full_name, call_original: false) + allow(Formulary).to receive(:loader_for).and_call_original if call_original + loader = double(get_formula: formula) allow(Formulary).to receive(:loader_for).with(ref, from: :keg).and_return(loader) allow(Formulary).to receive(:loader_for).with(ref, from: nil).and_return(loader) From b63b56f4c2193c76a6a8674db36816509a7ea498 Mon Sep 17 00:00:00 2001 From: William Ma Date: Mon, 17 Aug 2020 12:40:40 -0400 Subject: [PATCH 15/33] home: Remove warning for cask with same name --- Library/Homebrew/cmd/home.rb | 16 +--------------- Library/Homebrew/test/cli/named_args_spec.rb | 1 - 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/Library/Homebrew/cmd/home.rb b/Library/Homebrew/cmd/home.rb index cce7a1439b..318c7ffb02 100644 --- a/Library/Homebrew/cmd/home.rb +++ b/Library/Homebrew/cmd/home.rb @@ -25,10 +25,7 @@ module Homebrew end homepages = args.formulae_and_casks.map do |formula_or_cask| - disclaimer = disclaimers(formula_or_cask) - disclaimer = " (#{disclaimer})" if disclaimer.present? - - puts "Opening homepage for #{name_of(formula_or_cask)}#{disclaimer}" + puts "Opening homepage for #{name_of(formula_or_cask)}" formula_or_cask.homepage end @@ -42,15 +39,4 @@ module Homebrew "Cask #{formula_or_cask.token}" end end - - def disclaimers(formula_or_cask) - return unless formula_or_cask.is_a? Formula - - begin - cask = Cask::CaskLoader.load formula_or_cask.name - "for the cask, use #{cask.tap.name}/#{cask.token}" - rescue Cask::CaskUnavailableError - nil - end - end end diff --git a/Library/Homebrew/test/cli/named_args_spec.rb b/Library/Homebrew/test/cli/named_args_spec.rb index cccce6dc95..9ce8b4fd46 100644 --- a/Library/Homebrew/test/cli/named_args_spec.rb +++ b/Library/Homebrew/test/cli/named_args_spec.rb @@ -99,7 +99,6 @@ describe Homebrew::CLI::NamedArgs do named_args = described_class.new("foo", "baz") allow(named_args).to receive(:resolve_keg).and_call_original allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg - stub_cask_loader baz, call_original: true kegs, casks = named_args.to_kegs_to_casks From 540250063584c8df15b97d54294b0adda76fc529 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 17 Aug 2020 03:52:17 +0200 Subject: [PATCH 16/33] Refactor and document `Cleanup`. --- Library/Homebrew/cleanup.rb | 213 +++++++++++++------------- Library/Homebrew/test/cleanup_spec.rb | 4 +- 2 files changed, 111 insertions(+), 106 deletions(-) diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 7c904f506d..97f08c0251 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -6,126 +6,131 @@ require "formula" require "cask/cask_loader" require "set" -CLEANUP_DEFAULT_DAYS = 30 +module Homebrew + # Helper class for cleaning up the Homebrew cache. + # + # @api private + class Cleanup + CLEANUP_DEFAULT_DAYS = 30 + private_constant :CLEANUP_DEFAULT_DAYS -module CleanupRefinement - refine Pathname do - def incomplete? - extname.end_with?(".incomplete") - end + # `Pathname` refinement with helper functions for cleaning up files. + module CleanupRefinement + refine Pathname do + def incomplete? + extname.end_with?(".incomplete") + end - def nested_cache? - directory? && %w[ - cargo_cache - go_cache - go_mod_cache - glide_home - java_cache - npm_cache - gclient_cache - ].include?(basename.to_s) - end + def nested_cache? + directory? && %w[ + cargo_cache + go_cache + go_mod_cache + glide_home + java_cache + npm_cache + gclient_cache + ].include?(basename.to_s) + end - def go_cache_directory? - # Go makes its cache contents read-only to ensure cache integrity, - # which makes sense but is something we need to undo for cleanup. - directory? && %w[go_cache go_mod_cache].include?(basename.to_s) - end + def go_cache_directory? + # Go makes its cache contents read-only to ensure cache integrity, + # which makes sense but is something we need to undo for cleanup. + directory? && %w[go_cache go_mod_cache].include?(basename.to_s) + end - def prune?(days) - return false unless days - return true if days.zero? + def prune?(days) + return false unless days + return true if days.zero? - return true if symlink? && !exist? + return true if symlink? && !exist? - mtime < days.days.ago && ctime < days.days.ago - end + mtime < days.days.ago && ctime < days.days.ago + end - def stale?(scrub = false) - return false unless resolved_path.file? + def stale?(scrub = false) + return false unless resolved_path.file? - if dirname.basename.to_s == "Cask" - stale_cask?(scrub) - else - stale_formula?(scrub) - end - end + if dirname.basename.to_s == "Cask" + stale_cask?(scrub) + else + stale_formula?(scrub) + end + end - private + private - def stale_formula?(scrub) - return false unless HOMEBREW_CELLAR.directory? + def stale_formula?(scrub) + return false unless HOMEBREW_CELLAR.directory? - version = if to_s.match?(Pathname::BOTTLE_EXTNAME_RX) - begin - Utils::Bottles.resolve_version(self) - rescue - nil + version = if to_s.match?(Pathname::BOTTLE_EXTNAME_RX) + begin + Utils::Bottles.resolve_version(self) + rescue + nil + end + end + + version ||= basename.to_s[/\A.*(?:--.*?)*--(.*?)#{Regexp.escape(extname)}\Z/, 1] + version ||= basename.to_s[/\A.*--?(.*?)#{Regexp.escape(extname)}\Z/, 1] + + return false unless version + + version = Version.new(version) + + return false unless formula_name = basename.to_s[/\A(.*?)(?:--.*?)*--?(?:#{Regexp.escape(version)})/, 1] + + formula = begin + Formulary.from_rack(HOMEBREW_CELLAR/formula_name) + rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError + return false + end + + resource_name = basename.to_s[/\A.*?--(.*?)--?(?:#{Regexp.escape(version)})/, 1] + + if resource_name == "patch" + patch_hashes = formula.stable&.patches&.select(&:external?)&.map(&:resource)&.map(&:version) + return true unless patch_hashes&.include?(Checksum.new(:sha256, version.to_s)) + elsif resource_name && resource_version = formula.stable&.resources&.dig(resource_name)&.version + return true if resource_version != version + elsif version.is_a?(PkgVersion) + return true if formula.pkg_version > version + elsif formula.version > version + return true + end + + return true if scrub && !formula.latest_version_installed? + + return true if Utils::Bottles.file_outdated?(formula, self) + + false + end + + def stale_cask?(scrub) + return false unless name = basename.to_s[/\A(.*?)--/, 1] + + cask = begin + Cask::CaskLoader.load(name) + rescue Cask::CaskError + return false + end + + return true unless basename.to_s.match?(/\A#{Regexp.escape(name)}--#{Regexp.escape(cask.version)}\b/) + + return true if scrub && !cask.versions.include?(cask.version) + + if cask.version.latest? + return mtime < CLEANUP_DEFAULT_DAYS.days.ago && + ctime < CLEANUP_DEFAULT_DAYS.days.ago + end + + false end end - - version ||= basename.to_s[/\A.*(?:--.*?)*--(.*?)#{Regexp.escape(extname)}\Z/, 1] - version ||= basename.to_s[/\A.*--?(.*?)#{Regexp.escape(extname)}\Z/, 1] - - return false unless version - - version = Version.new(version) - - return false unless formula_name = basename.to_s[/\A(.*?)(?:--.*?)*--?(?:#{Regexp.escape(version)})/, 1] - - formula = begin - Formulary.from_rack(HOMEBREW_CELLAR/formula_name) - rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError - return false - end - - resource_name = basename.to_s[/\A.*?--(.*?)--?(?:#{Regexp.escape(version)})/, 1] - - if resource_name == "patch" - patch_hashes = formula.stable&.patches&.select(&:external?)&.map(&:resource)&.map(&:version) - return true unless patch_hashes&.include?(Checksum.new(:sha256, version.to_s)) - elsif resource_name && resource_version = formula.stable&.resources&.dig(resource_name)&.version - return true if resource_version != version - elsif version.is_a?(PkgVersion) - return true if formula.pkg_version > version - elsif formula.version > version - return true - end - - return true if scrub && !formula.latest_version_installed? - - return true if Utils::Bottles.file_outdated?(formula, self) - - false end - def stale_cask?(scrub) - return false unless name = basename.to_s[/\A(.*?)--/, 1] + using CleanupRefinement - cask = begin - Cask::CaskLoader.load(name) - rescue Cask::CaskError - return false - end - - return true unless basename.to_s.match?(/\A#{Regexp.escape(name)}--#{Regexp.escape(cask.version)}\b/) - - return true if scrub && !cask.versions.include?(cask.version) - - if cask.version.latest? - return mtime < CLEANUP_DEFAULT_DAYS.days.ago && - ctime < CLEANUP_DEFAULT_DAYS.days.ago - end - - false - end - end -end - -using CleanupRefinement - -module Homebrew - class Cleanup extend Predicable PERIODIC_CLEAN_FILE = (HOMEBREW_CACHE/".cleaned").freeze diff --git a/Library/Homebrew/test/cleanup_spec.rb b/Library/Homebrew/test/cleanup_spec.rb index 7993cdc7b2..c5cd2fb165 100644 --- a/Library/Homebrew/test/cleanup_spec.rb +++ b/Library/Homebrew/test/cleanup_spec.rb @@ -5,9 +5,9 @@ require "cleanup" require "cask/cache" require "fileutils" -using CleanupRefinement +using Homebrew::Cleanup::CleanupRefinement -describe CleanupRefinement do +describe Homebrew::Cleanup::CleanupRefinement do describe "::prune?" do alias_matcher :be_pruned, :be_prune From 7fce76d1761ce9782072d61ac529c38059b20acd Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 17 Aug 2020 18:39:55 +0200 Subject: [PATCH 17/33] Refactor and document `Install`. --- Library/Homebrew/extend/os/linux/install.rb | 13 +++++--- Library/Homebrew/formula_installer.rb | 5 +-- Library/Homebrew/install.rb | 37 ++++++++++++--------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/Library/Homebrew/extend/os/linux/install.rb b/Library/Homebrew/extend/os/linux/install.rb index 073c0c813d..2184287f53 100644 --- a/Library/Homebrew/extend/os/linux/install.rb +++ b/Library/Homebrew/extend/os/linux/install.rb @@ -14,6 +14,12 @@ module Homebrew "/system/bin/linker64", "/system/bin/linker", ].freeze + private_constant :DYNAMIC_LINKERS + + def perform_preinstall_checks(all_fatal: false, cc: nil) + generic_perform_preinstall_checks(all_fatal: all_fatal, cc: cc) + symlink_ld_so + end def check_cpu return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit? @@ -28,6 +34,7 @@ module Homebrew end abort message end + private_class_method :check_cpu def symlink_ld_so brew_ld_so = HOMEBREW_PREFIX/"lib/ld.so" @@ -42,10 +49,6 @@ module Homebrew FileUtils.mkdir_p HOMEBREW_PREFIX/"lib" FileUtils.ln_sf ld_so, brew_ld_so end - - def perform_preinstall_checks(all_fatal: false, cc: nil) - generic_perform_preinstall_checks(all_fatal: all_fatal, cc: cc) - symlink_ld_so - end + private_class_method :symlink_ld_so end end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 06d5db08b8..bb207ba2ef 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -21,7 +21,6 @@ require "cmd/install" require "find" class FormulaInstaller - include Homebrew::Install include FormulaCellarChecks extend Predicable @@ -261,7 +260,9 @@ class FormulaInstaller lock start_time = Time.now - perform_build_from_source_checks if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed? + if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed? + Homebrew::Install.perform_build_from_source_checks + end # not in initialize so upgrade can unlink the active keg before calling this # function but after instantiating this class so that it can avoid having to diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index f858d8f9d8..10f8df4547 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -6,9 +6,27 @@ require "hardware" require "development_tools" module Homebrew + # Helper module for performing (pre-)install checks. + # + # @api private module Install module_function + def perform_preinstall_checks(all_fatal: false, cc: nil) + check_cpu + attempt_directory_creation + check_cc_argv(cc) + diagnostic_checks(:supported_configuration_checks, fatal: all_fatal) + diagnostic_checks(:fatal_preinstall_checks) + end + alias generic_perform_preinstall_checks perform_preinstall_checks + module_function :generic_perform_preinstall_checks + + def perform_build_from_source_checks(all_fatal: false) + diagnostic_checks(:fatal_build_from_source_checks) + diagnostic_checks(:build_from_source_checks, fatal: all_fatal) + end + def check_cpu return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit? @@ -24,6 +42,7 @@ module Homebrew end abort message end + private_class_method :check_cpu def attempt_directory_creation Keg::MUST_EXIST_DIRECTORIES.each do |dir| @@ -38,6 +57,7 @@ module Homebrew nil end end + private_class_method :attempt_directory_creation def check_cc_argv(cc) return unless cc @@ -48,21 +68,7 @@ module Homebrew #{@checks.please_create_pull_requests} EOS end - - def perform_preinstall_checks(all_fatal: false, cc: nil) - check_cpu - attempt_directory_creation - check_cc_argv(cc) - diagnostic_checks(:supported_configuration_checks, fatal: all_fatal) - diagnostic_checks(:fatal_preinstall_checks) - end - alias generic_perform_preinstall_checks perform_preinstall_checks - module_function :generic_perform_preinstall_checks - - def perform_build_from_source_checks(all_fatal: false) - diagnostic_checks(:fatal_build_from_source_checks) - diagnostic_checks(:build_from_source_checks, fatal: all_fatal) - end + private_class_method :check_cc_argv def diagnostic_checks(type, fatal: true) @checks ||= Diagnostic::Checks.new @@ -80,6 +86,7 @@ module Homebrew end exit 1 if failed && fatal end + private_class_method :diagnostic_checks end end From db361e29b8d4909757e624fafdfb6186d0fe112a Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Mon, 17 Aug 2020 11:54:42 -0700 Subject: [PATCH 18/33] check_tmpdir_executable: Remove stray undent Fix the error: Error: undefined method undent for # .../extend/os/linux/diagnostic.rb:41:in check_tmpdir_executable --- Library/Homebrew/extend/os/linux/diagnostic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/linux/diagnostic.rb b/Library/Homebrew/extend/os/linux/diagnostic.rb index 61110bbec3..9e2fab3aaf 100644 --- a/Library/Homebrew/extend/os/linux/diagnostic.rb +++ b/Library/Homebrew/extend/os/linux/diagnostic.rb @@ -38,7 +38,7 @@ module Homebrew f.close return if system f.path - <<~EOS.undent + <<~EOS The directory #{HOMEBREW_TEMP} does not permit executing programs. It is likely mounted as "noexec". Please set HOMEBREW_TEMP in your #{shell_profile} to a different directory, for example: From 420e8fdbe4742eb655a58c7faabfca6fe200d4a8 Mon Sep 17 00:00:00 2001 From: Dustin Rodrigues Date: Sat, 15 Aug 2020 20:09:51 -0400 Subject: [PATCH 19/33] pr-automerge: pluralize message only when needed --- Library/Homebrew/dev-cmd/pr-automerge.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/pr-automerge.rb b/Library/Homebrew/dev-cmd/pr-automerge.rb index 24ed7f5d3d..78c4097a12 100644 --- a/Library/Homebrew/dev-cmd/pr-automerge.rb +++ b/Library/Homebrew/dev-cmd/pr-automerge.rb @@ -49,7 +49,7 @@ module Homebrew return end - ohai "#{prs.size} matching pull requests:" + ohai "#{prs.count} matching pull #{"request".pluralize(prs.count)}:" pr_urls = [] prs.each do |pr| puts "#{tap.full_name unless tap.core_tap?}##{pr["number"]}: #{pr["title"]}" From 08396a55c1105df5690a15bf1666647b66808160 Mon Sep 17 00:00:00 2001 From: Dustin Rodrigues Date: Fri, 14 Aug 2020 01:50:18 -0400 Subject: [PATCH 20/33] audit: always audit GitHub license --- Library/Homebrew/dev-cmd/audit.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 81332c148a..0cd05bbab1 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -350,6 +350,11 @@ module Homebrew "LGPL-3.0" => ["LGPL-3.0-only", "LGPL-3.0-or-later"], }.freeze + PERMITTED_FORMULA_LICENSE_MISMATCHES = { + "cmockery" => "0.1.2", + "scw@1" => "1.20", + }.freeze + def audit_license if formula.license.present? non_standard_licenses = formula.license.map do |license| @@ -380,12 +385,13 @@ module Homebrew return unless @online - user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula + user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) return if user.blank? github_license = GitHub.get_repo_license(user, repo) return if github_license && (formula.license + ["NOASSERTION"]).include?(github_license) return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| formula.license.include? license } + return if PERMITTED_FORMULA_LICENSE_MISMATCHES[formula.name] == formula.version problem "Formula license #{formula.license} does not match GitHub license #{Array(github_license)}." From 67d7d853615b795df884d2ed205772449780bf94 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 18 Aug 2020 13:32:19 +0000 Subject: [PATCH 21/33] build(deps): bump codecov from 0.2.5 to 0.2.6 in /Library/Homebrew Bumps [codecov](https://github.com/codecov/codecov-ruby) from 0.2.5 to 0.2.6. - [Release notes](https://github.com/codecov/codecov-ruby/releases) - [Changelog](https://github.com/codecov/codecov-ruby/blob/master/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-ruby/compare/v0.2.5...v0.2.6) Signed-off-by: dependabot-preview[bot] --- Library/Homebrew/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 6ac6cff31a..527212cc75 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -10,7 +10,7 @@ GEM ast (2.4.1) bindata (2.4.8) byebug (11.1.3) - codecov (0.2.5) + codecov (0.2.6) colorize json simplecov From e03c1a22c0ed58d1f7778982f0887eb1d2be0d18 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 18 Aug 2020 14:03:15 +0000 Subject: [PATCH 22/33] build(deps): bump simplecov from 0.18.5 to 0.19.0 in /Library/Homebrew Bumps [simplecov](https://github.com/simplecov-ruby/simplecov) from 0.18.5 to 0.19.0. - [Release notes](https://github.com/simplecov-ruby/simplecov/releases) - [Changelog](https://github.com/simplecov-ruby/simplecov/blob/main/CHANGELOG.md) - [Commits](https://github.com/simplecov-ruby/simplecov/compare/v0.18.5...v0.19.0) Signed-off-by: dependabot-preview[bot] --- Library/Homebrew/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 527212cc75..408f620de6 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -116,7 +116,7 @@ GEM rubocop (>= 0.87.0) ruby-macho (2.2.0) ruby-progressbar (1.10.1) - simplecov (0.18.5) + simplecov (0.19.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov-html (0.12.2) From 3918e13070b6675f9528f5bdaea4ccb5a5f6bb81 Mon Sep 17 00:00:00 2001 From: William Ma Date: Tue, 18 Aug 2020 09:30:53 -0400 Subject: [PATCH 23/33] cask --cache: Deprecate command --- Library/Homebrew/cask/cmd/--cache.rb | 3 +++ Library/Homebrew/cask/cmd/home.rb | 1 + Library/Homebrew/test/cask/cmd/cache_spec.rb | 13 ++++--------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cask/cmd/--cache.rb b/Library/Homebrew/cask/cmd/--cache.rb index 54aebf6c98..f674f59e59 100644 --- a/Library/Homebrew/cask/cmd/--cache.rb +++ b/Library/Homebrew/cask/cmd/--cache.rb @@ -18,6 +18,9 @@ module Cask end def run + # TODO: enable for next major/minor release + # odeprecated "brew cask --cache", "brew --cache --cask" + casks.each do |cask| puts self.class.cached_location(cask) end diff --git a/Library/Homebrew/cask/cmd/home.rb b/Library/Homebrew/cask/cmd/home.rb index 7774ed6544..690efd0145 100644 --- a/Library/Homebrew/cask/cmd/home.rb +++ b/Library/Homebrew/cask/cmd/home.rb @@ -8,6 +8,7 @@ module Cask end def run + # TODO: enable for next major/minor release # odeprecated "brew cask home", "brew home" if casks.none? diff --git a/Library/Homebrew/test/cask/cmd/cache_spec.rb b/Library/Homebrew/test/cask/cmd/cache_spec.rb index c84f9ed3ac..229edcc598 100644 --- a/Library/Homebrew/test/cask/cmd/cache_spec.rb +++ b/Library/Homebrew/test/cask/cmd/cache_spec.rb @@ -25,14 +25,9 @@ describe Cask::Cmd::Cache, :cask do cache: Cask::Cache.path, **local_caffeine.url.specs ).cached_location - expect do - described_class.run("local-transmission", "local-caffeine") - end.to output("#{transmission_location}\n#{caffeine_location}\n").to_stdout - end - - it "properly handles Casks that are not present" do - expect { - described_class.run("notacask") - }.to raise_error(Cask::CaskUnavailableError) + expect(described_class.cached_location(local_transmission)) + .to eql transmission_location + expect(described_class.cached_location(local_caffeine)) + .to eql caffeine_location end end From b338398a8c002953d64852c51f0d7b5e9c419332 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 6 Apr 2020 13:04:48 +0100 Subject: [PATCH 24/33] tab: add built_on & arch information --- Library/Homebrew/development_tools.rb | 9 +++++++++ Library/Homebrew/extend/os/mac/development_tools.rb | 8 ++++++++ Library/Homebrew/tab.rb | 4 ++++ Library/Homebrew/test/caveats_spec.rb | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index bec90038b1..b64c7b9312 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -99,6 +99,15 @@ class DevelopmentTools def subversion_handles_most_https_certificates? true end + + def build_system_info + { + "os" => ENV["HOMEBREW_SYSTEM"], + "os_version" => OS_VERSION, + "cpu_family" => Hardware::CPU.family, + } + end + alias generic_build_system_info build_system_info end end diff --git a/Library/Homebrew/extend/os/mac/development_tools.rb b/Library/Homebrew/extend/os/mac/development_tools.rb index e1b1d0e87b..787196472a 100644 --- a/Library/Homebrew/extend/os/mac/development_tools.rb +++ b/Library/Homebrew/extend/os/mac/development_tools.rb @@ -56,5 +56,13 @@ class DevelopmentTools brew install gcc EOS end + + def build_system_info + build_info = { + "xcode" => MacOS::Xcode.version.to_s.presence, + "clt" => MacOS::CLT.version.to_s.presence, + } + generic_build_system_info.merge build_info + end end end diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 8a3bdb13a1..d146533e5f 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -36,6 +36,7 @@ class Tab < OpenStruct "stdlib" => stdlib, "aliases" => formula.aliases, "runtime_dependencies" => Tab.runtime_deps_hash(runtime_deps), + "arch" => Hardware::CPU.arch, "source" => { "path" => formula.specified_path.to_s, "tap" => formula.tap&.name, @@ -47,6 +48,7 @@ class Tab < OpenStruct "version_scheme" => formula.version_scheme, }, }, + "built_on" => DevelopmentTools.build_system_info, } new(attributes) @@ -198,6 +200,7 @@ class Tab < OpenStruct "version_scheme" => 0, }, }, + "built_on" => DevelopmentTools.generic_build_system_info, } new(attributes) @@ -344,6 +347,7 @@ class Tab < OpenStruct "aliases" => aliases, "runtime_dependencies" => runtime_dependencies, "source" => source, + "built_on" => built_on, } JSON.generate(attributes, options) diff --git a/Library/Homebrew/test/caveats_spec.rb b/Library/Homebrew/test/caveats_spec.rb index ff010ff161..b0ed28814d 100644 --- a/Library/Homebrew/test/caveats_spec.rb +++ b/Library/Homebrew/test/caveats_spec.rb @@ -120,7 +120,7 @@ describe Caveats do "plist_test.plist" end end - allow(ENV).to receive(:[]).with("TMUX").and_return(true) + ENV["TMUX"] = "1" allow(Homebrew).to receive(:_system).with("/usr/bin/pbpaste").and_return(false) caveats = described_class.new(f).caveats From 82fc9506ad5ece82904c33545b43dccdc3ddb242 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 18 Aug 2020 15:58:46 +0100 Subject: [PATCH 25/33] simplecov: enable for subprocesses. Follow instructions in: https://github.com/simplecov-ruby/simplecov#running-simplecov-against-subprocesses --- Library/Homebrew/.simplecov | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Library/Homebrew/.simplecov b/Library/Homebrew/.simplecov index 2ed96ecf48..1b1f52138d 100755 --- a/Library/Homebrew/.simplecov +++ b/Library/Homebrew/.simplecov @@ -3,6 +3,8 @@ require "English" +SimpleCov.enable_for_subprocesses true + SimpleCov.start do coverage_dir File.expand_path("../test/coverage", File.realpath(__FILE__)) root File.expand_path("..", File.realpath(__FILE__)) @@ -12,9 +14,21 @@ SimpleCov.start do # tests to be dropped. This causes random fluctuations in test coverage. merge_timeout 86400 + at_fork do |pid| + # This needs a unique name so it won't be ovewritten + command_name "#{SimpleCov.command_name} (#{pid})" + + # be quiet, the parent process will be in charge of output and checking coverage totals + print_error_status = false + end + if ENV["HOMEBREW_INTEGRATION_TEST"] + # This needs a unique name so it won't be ovewritten command_name "#{ENV["HOMEBREW_INTEGRATION_TEST"]} (#{$PROCESS_ID})" + # be quiet, the parent process will be in charge of output and checking coverage totals + print_error_status = false + at_exit do exit_code = $ERROR_INFO.nil? ? 0 : $ERROR_INFO.status $stdout.reopen("/dev/null") From eb095eb899f4ec2412b06640d1bb25b445052262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= Date: Tue, 18 Aug 2020 16:14:30 +0100 Subject: [PATCH 26/33] Cask audit help: breakup desc string --- Library/Homebrew/cask/cmd/audit.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cask/cmd/audit.rb b/Library/Homebrew/cask/cmd/audit.rb index 612aeb370f..d03858c9a3 100644 --- a/Library/Homebrew/cask/cmd/audit.rb +++ b/Library/Homebrew/cask/cmd/audit.rb @@ -28,9 +28,9 @@ module Cask switch "--online", description: "Run additional, slower style checks that require a network connection" switch "--new-cask", - description: "Run various additional style checks to determine if a new cask is eligible - for Homebrew. This should be used when creating new casks and implies - `--strict` and `--online`" + description: "Run various additional style checks to determine if a new cask is eligible " \ + "for Homebrew. This should be used when creating new casks and implies " \ + "`--strict` and `--online`" end end From b123fca2270c4cd15167e70304004d14f9cc1983 Mon Sep 17 00:00:00 2001 From: William Ma Date: Tue, 18 Aug 2020 12:26:19 -0400 Subject: [PATCH 27/33] cask: Add TODOs to deprecate integrated cask cmds --- Library/Homebrew/cask/cmd.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Library/Homebrew/cask/cmd.rb b/Library/Homebrew/cask/cmd.rb index 1ce1cb3f2b..9de9fd7c9f 100644 --- a/Library/Homebrew/cask/cmd.rb +++ b/Library/Homebrew/cask/cmd.rb @@ -47,6 +47,16 @@ module Cask "dr" => "doctor", }.freeze + DEPRECATED_COMMANDS = { + Cmd::Cache => "brew --cache --cask", + Cmd::Doctor => "brew doctor --verbose", + Cmd::Home => "brew home", + Cmd::List => "brew list --cask", + Cmd::Outdated => "brew outdated --cask", + Cmd::Reinstall => "brew reinstall", + Cmd::Upgrade => "brew upgrade --cask", + }.freeze + def self.description max_command_len = Cmd.commands.map(&:length).max @@ -212,6 +222,11 @@ module Cask detect_external_command(*argv) || [args.remaining.empty? ? NullCommand : UnknownSubcommand.new(args.remaining.first), argv] + # TODO: enable for next major/minor release + # if (replacement = DEPRECATED_COMMANDS[command]) + # odeprecated "brew cask #{command.command_name}", replacement + # end + if args.help? puts command.help else From 543f421702cd0feb13c30979cb157d6e85503da0 Mon Sep 17 00:00:00 2001 From: William Ma Date: Tue, 18 Aug 2020 12:26:41 -0400 Subject: [PATCH 28/33] cask --cache: Remove deprecation comment --- Library/Homebrew/cask/cmd/--cache.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/Library/Homebrew/cask/cmd/--cache.rb b/Library/Homebrew/cask/cmd/--cache.rb index f674f59e59..54aebf6c98 100644 --- a/Library/Homebrew/cask/cmd/--cache.rb +++ b/Library/Homebrew/cask/cmd/--cache.rb @@ -18,9 +18,6 @@ module Cask end def run - # TODO: enable for next major/minor release - # odeprecated "brew cask --cache", "brew --cache --cask" - casks.each do |cask| puts self.class.cached_location(cask) end From e08891812843bbd732c98af1906fc843ac2712e9 Mon Sep 17 00:00:00 2001 From: William Ma Date: Tue, 18 Aug 2020 12:27:16 -0400 Subject: [PATCH 29/33] cask home: Remove deprecation comment --- Library/Homebrew/cask/cmd/home.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/Library/Homebrew/cask/cmd/home.rb b/Library/Homebrew/cask/cmd/home.rb index 690efd0145..22a32486ec 100644 --- a/Library/Homebrew/cask/cmd/home.rb +++ b/Library/Homebrew/cask/cmd/home.rb @@ -8,9 +8,6 @@ module Cask end def run - # TODO: enable for next major/minor release - # odeprecated "brew cask home", "brew home" - if casks.none? odebug "Opening project homepage" self.class.open_url "https://brew.sh/" From 77db066ae2cbb4d905c349d8efa1da5fd094b9af Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 18 Aug 2020 23:12:05 +0200 Subject: [PATCH 30/33] Add missing `summarize` method for `StageOnly`. --- Library/Homebrew/cask/artifact/stage_only.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/cask/artifact/stage_only.rb b/Library/Homebrew/cask/artifact/stage_only.rb index d0b2295c38..77ae227075 100644 --- a/Library/Homebrew/cask/artifact/stage_only.rb +++ b/Library/Homebrew/cask/artifact/stage_only.rb @@ -18,6 +18,10 @@ module Cask def to_a [true] end + + def summarize + "true" + end end end end From b43f17b2d0503dbec503e5a4d53441ed2eac6add Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Wed, 19 Aug 2020 09:25:32 +0100 Subject: [PATCH 31/33] formula_versions: handle references to too old MacOS in formulae --- Library/Homebrew/formula_versions.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index d6503bd22b..2fb219d85d 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -64,6 +64,9 @@ class FormulaVersions versions_seen = (map.keys + [f.pkg_version]).uniq.length end return map if versions_seen > MAX_VERSIONS_DEPTH + rescue MacOSVersionError => e + odebug "#{e} in #{name} at revision #{rev}" if debug? + break end map end From 85085da14c92405d076f7eaec984a8392be83202 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 19 Aug 2020 10:48:46 +0100 Subject: [PATCH 32/33] brew vendor-gems: commit updates. --- .../Homebrew/vendor/bundle/bundler/setup.rb | 8 +- .../lib/rubocop/cop/rspec/describe_class.rb | 72 -------- .../rubocop/cop/rspec/empty_example_group.rb | 90 --------- .../lib/rubocop/cop/rspec/variable_name.rb | 47 ----- .../lib/rubocop/rspec/top_level_group.rb | 44 ----- .../config/default.yml | 14 +- .../lib/rubocop-rspec.rb | 3 +- .../rubocop/cop/rspec/align_left_let_brace.rb | 2 +- .../cop/rspec/align_right_let_brace.rb | 2 +- .../lib/rubocop/cop/rspec/any_instance.rb | 2 +- .../lib/rubocop/cop/rspec/around_block.rb | 2 +- .../lib/rubocop/cop/rspec/base.rb} | 8 +- .../lib/rubocop/cop/rspec/be.rb | 2 +- .../lib/rubocop/cop/rspec/be_eql.rb | 2 +- .../lib/rubocop/cop/rspec/before_after_all.rb | 2 +- .../capybara/current_path_expectation.rb | 2 +- .../cop/rspec/capybara/feature_methods.rb | 9 +- .../cop/rspec/capybara/visibility_matcher.rb | 2 +- .../lib/rubocop/cop/rspec/context_method.rb | 4 +- .../lib/rubocop/cop/rspec/context_wording.rb | 6 +- .../lib/rubocop/cop/rspec/cop.rb | 10 + .../lib/rubocop/cop/rspec/describe_class.rb | 63 +++++++ .../lib/rubocop/cop/rspec/describe_method.rb | 20 +- .../lib/rubocop/cop/rspec/describe_symbol.rb | 4 +- .../lib/rubocop/cop/rspec/described_class.rb | 4 +- .../rspec/described_class_module_wrapping.rb | 2 +- .../lib/rubocop/cop/rspec/dialect.rb | 2 +- .../rubocop/cop/rspec/empty_example_group.rb | 174 ++++++++++++++++++ .../lib/rubocop/cop/rspec/empty_hook.rb | 2 +- .../cop/rspec/empty_line_after_example.rb | 12 +- .../rspec/empty_line_after_example_group.rb | 12 +- .../cop/rspec/empty_line_after_final_let.rb | 17 +- .../cop/rspec/empty_line_after_hook.rb | 12 +- .../cop/rspec/empty_line_after_subject.rb | 13 +- .../lib/rubocop/cop/rspec/example_length.rb | 2 +- .../cop/rspec/example_without_description.rb | 2 +- .../lib/rubocop/cop/rspec/example_wording.rb | 8 +- .../lib/rubocop/cop/rspec/expect_actual.rb | 2 +- .../lib/rubocop/cop/rspec/expect_change.rb | 2 +- .../lib/rubocop/cop/rspec/expect_in_hook.rb | 2 +- .../lib/rubocop/cop/rspec/expect_output.rb | 2 +- .../attribute_defined_statically.rb | 6 +- .../cop/rspec/factory_bot/create_list.rb | 16 +- .../rspec/factory_bot/factory_class_name.rb | 2 +- .../lib/rubocop/cop/rspec/file_path.rb | 42 +++-- .../lib/rubocop/cop/rspec/focus.rb | 18 +- .../lib/rubocop/cop/rspec/hook_argument.rb | 11 +- .../cop/rspec/hooks_before_examples.rb | 2 +- .../cop/rspec/implicit_block_expectation.rb | 2 +- .../lib/rubocop/cop/rspec/implicit_expect.rb | 2 +- .../lib/rubocop/cop/rspec/implicit_subject.rb | 14 +- .../lib/rubocop/cop/rspec/instance_spy.rb | 2 +- .../rubocop/cop/rspec/instance_variable.rb | 2 +- .../cop/rspec/invalid_predicate_matcher.rb | 2 +- .../lib/rubocop/cop/rspec/it_behaves_like.rb | 2 +- .../rubocop/cop/rspec/iterated_expectation.rb | 2 +- .../lib/rubocop/cop/rspec/leading_subject.rb | 37 ++-- .../cop/rspec/leaky_constant_declaration.rb | 2 +- .../rubocop/cop/rspec/let_before_examples.rb | 2 +- .../lib/rubocop/cop/rspec/let_setup.rb | 9 +- .../lib/rubocop/cop/rspec/message_chain.rb | 2 +- .../rubocop/cop/rspec/message_expectation.rb | 2 +- .../lib/rubocop/cop/rspec/message_spies.rb | 2 +- .../rspec/missing_example_group_argument.rb | 2 +- .../rubocop/cop/rspec/multiple_describes.rb | 19 +- .../cop/rspec/multiple_expectations.rb | 18 +- .../cop/rspec/multiple_memoized_helpers.rb | 148 +++++++++++++++ .../rubocop/cop/rspec/multiple_subjects.rb | 2 +- .../lib/rubocop/cop/rspec/named_subject.rb | 2 +- .../lib/rubocop/cop/rspec/nested_groups.rb | 8 +- .../lib/rubocop/cop/rspec/not_to_not.rb | 2 +- .../rubocop/cop/rspec/overwriting_setup.rb | 2 +- .../lib/rubocop/cop/rspec/pending.rb | 2 +- .../rubocop/cop/rspec/predicate_matcher.rb | 21 +-- .../rubocop/cop/rspec/rails/http_status.rb | 2 +- .../lib/rubocop/cop/rspec/receive_counts.rb | 2 +- .../lib/rubocop/cop/rspec/receive_never.rb | 4 +- .../rubocop/cop/rspec/repeated_description.rb | 2 +- .../lib/rubocop/cop/rspec/repeated_example.rb | 4 +- .../cop/rspec/repeated_example_group_body.rb | 2 +- .../repeated_example_group_description.rb | 2 +- .../lib/rubocop/cop/rspec/return_from_stub.rb | 2 +- .../lib/rubocop/cop/rspec/scattered_let.rb | 2 +- .../lib/rubocop/cop/rspec/scattered_setup.rb | 2 +- .../lib/rubocop/cop/rspec/shared_context.rb | 2 +- .../lib/rubocop/cop/rspec/shared_examples.rb | 2 +- .../rspec/single_argument_message_chain.rb | 2 +- .../lib/rubocop/cop/rspec/subject_stub.rb | 4 +- .../cop/rspec/unspecified_exception.rb | 2 +- .../rubocop/cop/rspec/variable_definition.rb | 12 +- .../lib/rubocop/cop/rspec/variable_name.rb | 66 +++++++ .../lib/rubocop/cop/rspec/verified_doubles.rb | 2 +- .../lib/rubocop/cop/rspec/void_expect.rb | 2 +- .../lib/rubocop/cop/rspec/yield.rb | 2 +- .../lib/rubocop/cop/rspec_cops.rb | 1 + .../lib/rubocop/rspec.rb | 0 .../lib/rubocop/rspec/align_let_brace.rb | 0 .../lib/rubocop/rspec/concept.rb | 0 .../lib/rubocop/rspec/config_formatter.rb | 0 .../lib/rubocop/rspec/corrector/move_node.rb | 12 +- .../rubocop/rspec/description_extractor.rb | 2 +- .../rubocop/rspec/empty_line_separation.rb} | 15 +- .../lib/rubocop/rspec/example.rb | 0 .../lib/rubocop/rspec/example_group.rb | 4 +- .../lib/rubocop/rspec/factory_bot.rb | 0 .../lib/rubocop/rspec/final_end_location.rb | 0 .../lib/rubocop/rspec/hook.rb | 0 .../lib/rubocop/rspec/inject.rb | 0 .../lib/rubocop/rspec/language.rb | 10 +- .../rubocop/rspec/language/node_pattern.rb | 7 +- .../lib/rubocop/rspec/node.rb | 0 .../lib/rubocop/rspec/top_level_describe.rb | 4 +- .../lib/rubocop/rspec/top_level_group.rb | 57 ++++++ .../lib/rubocop/rspec/variable.rb | 2 +- .../lib/rubocop/rspec/version.rb | 2 +- .../lib/rubocop/rspec/wording.rb | 0 116 files changed, 815 insertions(+), 518 deletions(-) delete mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/describe_class.rb delete mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/empty_example_group.rb delete mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/variable_name.rb delete mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/rspec/top_level_group.rb rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/config/default.yml (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop-rspec.rb (93%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/align_left_let_brace.rb (96%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/align_right_let_brace.rb (96%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/any_instance.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/around_block.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/cop.rb => rubocop-rspec-1.43.1/lib/rubocop/cop/rspec/base.rb} (90%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/be.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/be_eql.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/before_after_all.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/capybara/feature_methods.rb (92%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/context_method.rb (90%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/context_wording.rb (90%) create mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.43.1/lib/rubocop/cop/rspec/cop.rb create mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.43.1/lib/rubocop/cop/rspec/describe_class.rb rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/describe_method.rb (54%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/describe_symbol.rb (89%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/described_class.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/described_class_module_wrapping.rb (94%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/dialect.rb (98%) create mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.43.1/lib/rubocop/cop/rspec/empty_example_group.rb rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/empty_hook.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/empty_line_after_example.rb (83%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/empty_line_after_example_group.rb (65%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/empty_line_after_final_let.rb (53%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/empty_line_after_hook.rb (71%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/empty_line_after_subject.rb (67%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/example_length.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/example_without_description.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/example_wording.rb (94%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/expect_actual.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/expect_change.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/expect_in_hook.rb (96%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/expect_output.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb (94%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/factory_bot/create_list.rb (94%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/file_path.rb (79%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/focus.rb (68%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/hook_argument.rb (90%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/hooks_before_examples.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/implicit_block_expectation.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/implicit_expect.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/implicit_subject.rb (86%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/instance_spy.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/instance_variable.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb (96%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/it_behaves_like.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/iterated_expectation.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/leading_subject.rb (70%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/leaky_constant_declaration.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/let_before_examples.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/let_setup.rb (89%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/message_chain.rb (96%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/message_expectation.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/message_spies.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/missing_example_group_argument.rb (93%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/multiple_describes.rb (56%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/multiple_expectations.rb (87%) create mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.43.1/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/multiple_subjects.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/named_subject.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/nested_groups.rb (94%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/not_to_not.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/overwriting_setup.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/pending.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/predicate_matcher.rb (95%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/rails/http_status.rb (99%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/receive_counts.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/receive_never.rb (89%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/repeated_description.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/repeated_example.rb (93%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/repeated_example_group_body.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/repeated_example_group_description.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/return_from_stub.rb (99%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/scattered_let.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/scattered_setup.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/shared_context.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/shared_examples.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/single_argument_message_chain.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/subject_stub.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/unspecified_exception.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/variable_definition.rb (94%) create mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.43.1/lib/rubocop/cop/rspec/variable_name.rb rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/verified_doubles.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/void_expect.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec/yield.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/cop/rspec_cops.rb (98%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/align_let_brace.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/concept.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/config_formatter.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/corrector/move_node.rb (76%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/description_extractor.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0/lib/rubocop/rspec/blank_line_separation.rb => rubocop-rspec-1.43.1/lib/rubocop/rspec/empty_line_separation.rb} (67%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/example.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/example_group.rb (91%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/factory_bot.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/final_end_location.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/hook.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/inject.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/language.rb (92%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/language/node_pattern.rb (77%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/node.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/top_level_describe.rb (91%) create mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.43.1/lib/rubocop/rspec/top_level_group.rb rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/variable.rb (81%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/version.rb (86%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{rubocop-rspec-1.42.0 => rubocop-rspec-1.43.1}/lib/rubocop/rspec/wording.rb (100%) diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index c094822c7f..f9a2a94fd0 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -51,7 +51,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.19.2/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-3.1.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.7.1.4/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.0.0/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-0.5.5866/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-0.5.5869/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parlour-4.0.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/patchelf-1.2.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib" @@ -74,9 +74,9 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10 $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.7.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.88.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.7.1/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.42.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.43.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-static-0.5.5866-universal-darwin-19/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-0.5.5866/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-static-0.5.5869-universal-darwin-19/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-0.5.5869/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thor-1.0.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tapioca-0.4.1/lib" diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/describe_class.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/describe_class.rb deleted file mode 100644 index 6bdf4ffb9e..0000000000 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/describe_class.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module Cop - module RSpec - # Check that the first argument to the top level describe is a constant. - # - # @example - # # bad - # describe 'Do something' do - # end - # - # # good - # describe TestedClass do - # subject { described_class } - # end - # - # describe 'TestedClass::VERSION' do - # subject { Object.const_get(self.class.description) } - # end - # - # describe "A feature example", type: :feature do - # end - class DescribeClass < Cop - include RuboCop::RSpec::TopLevelDescribe - - MSG = 'The first argument to describe should be '\ - 'the class or module being tested.' - - def_node_matcher :valid_describe?, <<-PATTERN - { - (send #{RSPEC} :describe const ...) - (send #{RSPEC} :describe) - } - PATTERN - - def_node_matcher :describe_with_rails_metadata?, <<-PATTERN - (send #{RSPEC} :describe !const ... - (hash <#rails_metadata? ...>) - ) - PATTERN - - def_node_matcher :rails_metadata?, <<-PATTERN - (pair - (sym :type) - (sym { - :channel :controller :helper :job :mailer :model :request - :routing :view :feature :system :mailbox - } - ) - ) - PATTERN - - def on_top_level_describe(node, (described_value, _)) - return if shared_group?(root_node) - return if valid_describe?(node) - return if describe_with_rails_metadata?(node) - return if string_constant_describe?(described_value) - - add_offense(described_value) - end - - private - - def string_constant_describe?(described_value) - described_value.str_type? && - described_value.value =~ /^((::)?[A-Z]\w*)+$/ - end - end - end - end -end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/empty_example_group.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/empty_example_group.rb deleted file mode 100644 index 2d8bb24f49..0000000000 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/empty_example_group.rb +++ /dev/null @@ -1,90 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module Cop - module RSpec - # Checks if an example group does not include any tests. - # - # This cop is configurable using the `CustomIncludeMethods` option - # - # @example usage - # - # # bad - # describe Bacon do - # let(:bacon) { Bacon.new(chunkiness) } - # let(:chunkiness) { false } - # - # context 'extra chunky' do # flagged by rubocop - # let(:chunkiness) { true } - # end - # - # it 'is chunky' do - # expect(bacon.chunky?).to be_truthy - # end - # end - # - # # good - # describe Bacon do - # let(:bacon) { Bacon.new(chunkiness) } - # let(:chunkiness) { false } - # - # it 'is chunky' do - # expect(bacon.chunky?).to be_truthy - # end - # end - # - # @example configuration - # - # # .rubocop.yml - # # RSpec/EmptyExampleGroup: - # # CustomIncludeMethods: - # # - include_tests - # - # # spec_helper.rb - # RSpec.configure do |config| - # config.alias_it_behaves_like_to(:include_tests) - # end - # - # # bacon_spec.rb - # describe Bacon do - # let(:bacon) { Bacon.new(chunkiness) } - # let(:chunkiness) { false } - # - # context 'extra chunky' do # not flagged by rubocop - # let(:chunkiness) { true } - # - # include_tests 'shared tests' - # end - # end - # - class EmptyExampleGroup < Cop - MSG = 'Empty example group detected.' - - def_node_search :contains_example?, <<-PATTERN - { - #{(Examples::ALL + Includes::ALL).send_pattern} - (send _ #custom_include? ...) - } - PATTERN - - def on_block(node) - return unless example_group?(node) && !contains_example?(node) - - add_offense(node.send_node) - end - - private - - def custom_include?(method_name) - custom_include_methods.include?(method_name) - end - - def custom_include_methods - cop_config - .fetch('CustomIncludeMethods', []) - .map(&:to_sym) - end - end - end - end -end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/variable_name.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/variable_name.rb deleted file mode 100644 index 7fa222805d..0000000000 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-1.42.0/lib/rubocop/cop/rspec/variable_name.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module Cop - module RSpec - # Checks that memoized helper names use the configured style. - # - # @example EnforcedStyle: snake_case (default) - # # bad - # let(:userName) { 'Adam' } - # subject(:userName) { 'Adam' } - # - # # good - # let(:user_name) { 'Adam' } - # subject(:user_name) { 'Adam' } - # - # @example EnforcedStyle: camelCase - # # bad - # let(:user_name) { 'Adam' } - # subject(:user_name) { 'Adam' } - # - # # good - # let(:userName) { 'Adam' } - # subject(:userName) { 'Adam' } - class VariableName < Cop - include ConfigurableNaming - include RuboCop::RSpec::Variable - - MSG = 'Use %