Merge pull request #5768 from Homebrew/dependabot/bundler/Library/Homebrew/test/rubocop-0.65.0
Bump rubocop from 0.64.0 to 0.65.0 in /Library/Homebrew/test
This commit is contained in:
		
						commit
						d878af6b52
					
				@ -37,10 +37,6 @@ Layout/EndAlignment:
 | 
			
		||||
Layout/SpaceAroundOperators:
 | 
			
		||||
  Enabled: false
 | 
			
		||||
 | 
			
		||||
# Auto-correct is broken (https://github.com/rubocop-hq/rubocop/issues/6300).
 | 
			
		||||
Layout/EmptyLineAfterGuardClause:
 | 
			
		||||
  Enabled: false
 | 
			
		||||
 | 
			
		||||
# Auto-correct is broken (https://github.com/rubocop-hq/rubocop/issues/6258)
 | 
			
		||||
# and layout is not configurable (https://github.com/rubocop-hq/rubocop/issues/6254).
 | 
			
		||||
Layout/RescueEnsureAlignment:
 | 
			
		||||
 | 
			
		||||
@ -49,8 +49,7 @@ Style/CollectionMethods:
 | 
			
		||||
Style/FormatStringToken:
 | 
			
		||||
  EnforcedStyle: template
 | 
			
		||||
 | 
			
		||||
# This often leads to lines longer than the maximum line length.
 | 
			
		||||
# https://github.com/rubocop-hq/rubocop/issues/6149
 | 
			
		||||
# This shouldn't be enabled until LineLength is lower.
 | 
			
		||||
Style/IfUnlessModifier:
 | 
			
		||||
  Enabled: false
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -125,6 +125,10 @@ Style/GuardClause:
 | 
			
		||||
Style/HashSyntax:
 | 
			
		||||
  EnforcedStyle: ruby19_no_mixed_keys
 | 
			
		||||
 | 
			
		||||
# LineLength is low enough here to re-enable it.
 | 
			
		||||
Style/IfUnlessModifier:
 | 
			
		||||
  Enabled: true
 | 
			
		||||
 | 
			
		||||
# so many of these in formulae but none in here
 | 
			
		||||
Style/TrailingBodyOnMethodDefinition:
 | 
			
		||||
  Enabled: true
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,4 @@
 | 
			
		||||
unless ENV["HOMEBREW_BREW_FILE"]
 | 
			
		||||
  raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
 | 
			
		||||
end
 | 
			
		||||
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
 | 
			
		||||
 | 
			
		||||
std_trap = trap("INT") { exit! 130 } # no backtrace thanks
 | 
			
		||||
 | 
			
		||||
@ -10,6 +8,12 @@ if RUBY_X < 2 || (RUBY_X == 2 && RUBY_Y < 3)
 | 
			
		||||
  raise "Homebrew must be run under Ruby 2.3! You're running #{RUBY_VERSION}."
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# Load Bundler first of all if it's needed to avoid Gem version conflicts.
 | 
			
		||||
if ENV["HOMEBREW_INSTALL_BUNDLER_GEMS_FIRST"]
 | 
			
		||||
  require_relative "utils/gems"
 | 
			
		||||
  Homebrew.install_bundler_gems!
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# Also define here so we can rescue regardless of location.
 | 
			
		||||
class MissingEnvironmentVariables < RuntimeError; end
 | 
			
		||||
 | 
			
		||||
@ -92,9 +96,7 @@ begin
 | 
			
		||||
    # `Homebrew.help` never returns, except for external/unknown commands.
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  if ENV["HOMEBREW_BUILD_FROM_SOURCE"]
 | 
			
		||||
    odisabled("HOMEBREW_BUILD_FROM_SOURCE", "--build-from-source")
 | 
			
		||||
  end
 | 
			
		||||
  odisabled("HOMEBREW_BUILD_FROM_SOURCE", "--build-from-source") if ENV["HOMEBREW_BUILD_FROM_SOURCE"]
 | 
			
		||||
 | 
			
		||||
  if internal_cmd
 | 
			
		||||
    Homebrew.send cmd.to_s.tr("-", "_").downcase
 | 
			
		||||
@ -113,9 +115,7 @@ begin
 | 
			
		||||
 | 
			
		||||
    brew_uid = HOMEBREW_BREW_FILE.stat.uid
 | 
			
		||||
    tap_commands = []
 | 
			
		||||
    if Process.uid.zero? && !brew_uid.zero?
 | 
			
		||||
      tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}]
 | 
			
		||||
    end
 | 
			
		||||
    tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}] if Process.uid.zero? && !brew_uid.zero?
 | 
			
		||||
    # Unset HOMEBREW_HELP to avoid confusing the tap
 | 
			
		||||
    ENV.delete("HOMEBREW_HELP") if help_flag
 | 
			
		||||
    tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{possible_tap}]
 | 
			
		||||
 | 
			
		||||
@ -309,6 +309,11 @@ then
 | 
			
		||||
  esac
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ "$HOMEBREW_COMMAND" = "audit" || "$HOMEBREW_COMMAND" = "style" ]]
 | 
			
		||||
then
 | 
			
		||||
  export HOMEBREW_INSTALL_BUNDLER_GEMS_FIRST="1"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Set HOMEBREW_DEV_CMD_RUN for users who have run a development command.
 | 
			
		||||
# This makes them behave like HOMEBREW_DEVELOPERs for brew update.
 | 
			
		||||
if [[ -z "$HOMEBREW_DEVELOPER" ]]
 | 
			
		||||
 | 
			
		||||
@ -39,6 +39,7 @@ class CacheStoreDatabase
 | 
			
		||||
  # Closes the underlying database (if it is created and open).
 | 
			
		||||
  def close_if_open!
 | 
			
		||||
    return unless @db
 | 
			
		||||
 | 
			
		||||
    cache_path.dirname.mkpath
 | 
			
		||||
    cache_path.atomic_write(JSON.dump(@db))
 | 
			
		||||
  end
 | 
			
		||||
@ -55,6 +56,7 @@ class CacheStoreDatabase
 | 
			
		||||
  # @return [Time]
 | 
			
		||||
  def mtime
 | 
			
		||||
    return unless created?
 | 
			
		||||
 | 
			
		||||
    cache_path.mtime
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -136,6 +136,7 @@ module Cask
 | 
			
		||||
            Timeout.timeout(10) do
 | 
			
		||||
              Kernel.loop do
 | 
			
		||||
                next unless quit(bundle_id).success?
 | 
			
		||||
 | 
			
		||||
                if running_processes(bundle_id).empty?
 | 
			
		||||
                  puts "Application '#{bundle_id}' quit successfully."
 | 
			
		||||
                  break
 | 
			
		||||
@ -179,9 +180,7 @@ module Cask
 | 
			
		||||
      # :signal should come after :quit so it can be used as a backup when :quit fails
 | 
			
		||||
      def uninstall_signal(*signals, command: nil, **_)
 | 
			
		||||
        signals.each do |pair|
 | 
			
		||||
          unless pair.size == 2
 | 
			
		||||
            raise CaskInvalidError.new(cask, "Each #{stanza} :signal must consist of 2 elements.")
 | 
			
		||||
          end
 | 
			
		||||
          raise CaskInvalidError.new(cask, "Each #{stanza} :signal must consist of 2 elements.") unless pair.size == 2
 | 
			
		||||
 | 
			
		||||
          signal, bundle_id = pair
 | 
			
		||||
          ohai "Signalling '#{signal}' to application ID '#{bundle_id}'"
 | 
			
		||||
 | 
			
		||||
@ -13,9 +13,7 @@ module Cask
 | 
			
		||||
      def self.from_args(cask, *args)
 | 
			
		||||
        source_string, target_hash = args
 | 
			
		||||
 | 
			
		||||
        if source_string.nil?
 | 
			
		||||
          raise CaskInvalidError.new(cask.token, "no source given for #{english_name}")
 | 
			
		||||
        end
 | 
			
		||||
        raise CaskInvalidError.new(cask.token, "no source given for #{english_name}") if source_string.nil?
 | 
			
		||||
 | 
			
		||||
        unless target_hash.is_a?(Hash)
 | 
			
		||||
          raise CaskInvalidError.new(cask.token, "target required for #{english_name} '#{source_string}'")
 | 
			
		||||
 | 
			
		||||
@ -32,9 +32,7 @@ module Cask
 | 
			
		||||
            cask.staged_path.join(path)
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          if absolute_path.exist? && !absolute_path.executable?
 | 
			
		||||
            FileUtils.chmod "+x", absolute_path
 | 
			
		||||
          end
 | 
			
		||||
          FileUtils.chmod "+x", absolute_path if absolute_path.exist? && !absolute_path.executable?
 | 
			
		||||
 | 
			
		||||
          executable = if absolute_path.exist?
 | 
			
		||||
            absolute_path
 | 
			
		||||
 | 
			
		||||
@ -46,9 +46,7 @@ module Cask
 | 
			
		||||
          "-target", "/"
 | 
			
		||||
        ]
 | 
			
		||||
        args << "-verboseR" if verbose
 | 
			
		||||
        if stanza_options.fetch(:allow_untrusted, false)
 | 
			
		||||
          args << "-allowUntrusted"
 | 
			
		||||
        end
 | 
			
		||||
        args << "-allowUntrusted" if stanza_options.fetch(:allow_untrusted, false)
 | 
			
		||||
        with_choices_file do |choices_path|
 | 
			
		||||
          args << "-applyChoiceChangesXML" << choices_path if choices_path
 | 
			
		||||
          env = {
 | 
			
		||||
 | 
			
		||||
@ -4,9 +4,7 @@ module Cask
 | 
			
		||||
  module Artifact
 | 
			
		||||
    class StageOnly < AbstractArtifact
 | 
			
		||||
      def self.from_args(cask, *args)
 | 
			
		||||
        if args != [true]
 | 
			
		||||
          raise CaskInvalidError.new(cask.token, "'stage_only' takes only a single argument: true")
 | 
			
		||||
        end
 | 
			
		||||
        raise CaskInvalidError.new(cask.token, "'stage_only' takes only a single argument: true") if args != [true]
 | 
			
		||||
 | 
			
		||||
        new(cask)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -106,18 +106,14 @@ module Cask
 | 
			
		||||
          k.directives.key?(:uninstall_preflight)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if count > 1
 | 
			
		||||
        add_warning "only a single uninstall_preflight stanza is allowed"
 | 
			
		||||
      end
 | 
			
		||||
      add_warning "only a single uninstall_preflight stanza is allowed" if count > 1
 | 
			
		||||
 | 
			
		||||
      count = cask.artifacts.count do |k|
 | 
			
		||||
        k.is_a?(Artifact::PostflightBlock) &&
 | 
			
		||||
          k.directives.key?(:uninstall_postflight)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if count > 1
 | 
			
		||||
        add_warning "only a single uninstall_postflight stanza is allowed"
 | 
			
		||||
      end
 | 
			
		||||
      add_warning "only a single uninstall_postflight stanza is allowed" if count > 1
 | 
			
		||||
 | 
			
		||||
      return unless cask.artifacts.count { |k| k.is_a?(Artifact::Zap) } > 1
 | 
			
		||||
 | 
			
		||||
@ -296,6 +292,7 @@ module Cask
 | 
			
		||||
 | 
			
		||||
    def check_https_availability
 | 
			
		||||
      return unless download
 | 
			
		||||
 | 
			
		||||
      if !cask.url.blank? && !cask.url.using
 | 
			
		||||
        check_url_for_https_availability(cask.url, user_agents: [cask.url.user_agent])
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -58,9 +58,7 @@ module Cask
 | 
			
		||||
 | 
			
		||||
        begin
 | 
			
		||||
          instance_eval(content, path).tap do |cask|
 | 
			
		||||
            unless cask.is_a?(Cask)
 | 
			
		||||
              raise CaskUnreadableError.new(token, "'#{path}' does not contain a cask.")
 | 
			
		||||
            end
 | 
			
		||||
            raise CaskUnreadableError.new(token, "'#{path}' does not contain a cask.") unless cask.is_a?(Cask)
 | 
			
		||||
          end
 | 
			
		||||
        rescue NameError, ArgumentError, ScriptError => e
 | 
			
		||||
          raise CaskUnreadableError.new(token, e.message)
 | 
			
		||||
@ -70,9 +68,7 @@ module Cask
 | 
			
		||||
      private
 | 
			
		||||
 | 
			
		||||
      def cask(header_token, **options, &block)
 | 
			
		||||
        if token != header_token
 | 
			
		||||
          raise CaskTokenMismatchError.new(token, header_token)
 | 
			
		||||
        end
 | 
			
		||||
        raise CaskTokenMismatchError.new(token, header_token) if token != header_token
 | 
			
		||||
 | 
			
		||||
        super(header_token, **options, sourcefile_path: path, &block)
 | 
			
		||||
      end
 | 
			
		||||
@ -192,9 +188,7 @@ module Cask
 | 
			
		||||
        return loader_class.new(ref) if loader_class.can_load?(ref)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if FromTapPathLoader.can_load?(default_path(ref))
 | 
			
		||||
        return FromTapPathLoader.new(default_path(ref))
 | 
			
		||||
      end
 | 
			
		||||
      return FromTapPathLoader.new(default_path(ref)) if FromTapPathLoader.can_load?(default_path(ref))
 | 
			
		||||
 | 
			
		||||
      case (possible_tap_casks = tap_paths(ref)).count
 | 
			
		||||
      when 1
 | 
			
		||||
@ -209,9 +203,7 @@ module Cask
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      possible_installed_cask = Cask.new(ref)
 | 
			
		||||
      if possible_installed_cask.installed?
 | 
			
		||||
        return FromPathLoader.new(possible_installed_cask.installed_caskfile)
 | 
			
		||||
      end
 | 
			
		||||
      return FromPathLoader.new(possible_installed_cask.installed_caskfile) if possible_installed_cask.installed?
 | 
			
		||||
 | 
			
		||||
      NullLoader.new(ref)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -63,6 +63,7 @@ module Cask
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        return if failed.empty?
 | 
			
		||||
 | 
			
		||||
        $stderr.puts
 | 
			
		||||
        raise CaskError, "Failed merging the following PRs:\n#{failed.join("\n")}"
 | 
			
		||||
      end
 | 
			
		||||
@ -90,8 +91,10 @@ module Cask
 | 
			
		||||
 | 
			
		||||
      def diff_is_single_cask(diff)
 | 
			
		||||
        return false unless diff.files.count == 1
 | 
			
		||||
 | 
			
		||||
        file = diff.files.first
 | 
			
		||||
        return false unless file.a_path == file.b_path
 | 
			
		||||
 | 
			
		||||
        file.a_path.match?(%r{\ACasks/[^/]+\.rb\Z})
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -131,9 +131,7 @@ module Cask
 | 
			
		||||
 | 
			
		||||
      return @language = nil if @language_blocks.nil? || @language_blocks.empty?
 | 
			
		||||
 | 
			
		||||
      if @language_blocks.default.nil?
 | 
			
		||||
        raise CaskInvalidError.new(cask, "No default language specified.")
 | 
			
		||||
      end
 | 
			
		||||
      raise CaskInvalidError.new(cask, "No default language specified.") if @language_blocks.default.nil?
 | 
			
		||||
 | 
			
		||||
      locales = MacOS.languages
 | 
			
		||||
                     .map do |language|
 | 
			
		||||
 | 
			
		||||
@ -82,9 +82,7 @@ module Cask
 | 
			
		||||
 | 
			
		||||
      old_config = @cask.config
 | 
			
		||||
 | 
			
		||||
      if @cask.installed? && !force? && !reinstall? && !upgrade?
 | 
			
		||||
        raise CaskAlreadyInstalledError, @cask
 | 
			
		||||
      end
 | 
			
		||||
      raise CaskAlreadyInstalledError, @cask if @cask.installed? && !force? && !reinstall? && !upgrade?
 | 
			
		||||
 | 
			
		||||
      check_conflicts
 | 
			
		||||
 | 
			
		||||
@ -100,9 +98,7 @@ module Cask
 | 
			
		||||
 | 
			
		||||
      install_artifacts
 | 
			
		||||
 | 
			
		||||
      unless @cask.tap&.private?
 | 
			
		||||
        ::Utils::Analytics.report_event("cask_install", @cask.token)
 | 
			
		||||
      end
 | 
			
		||||
      ::Utils::Analytics.report_event("cask_install", @cask.token) unless @cask.tap&.private?
 | 
			
		||||
 | 
			
		||||
      puts summary
 | 
			
		||||
    end
 | 
			
		||||
@ -113,9 +109,7 @@ module Cask
 | 
			
		||||
      @cask.conflicts_with[:cask].each do |conflicting_cask|
 | 
			
		||||
        begin
 | 
			
		||||
          conflicting_cask = CaskLoader.load(conflicting_cask)
 | 
			
		||||
          if conflicting_cask.installed?
 | 
			
		||||
            raise CaskConflictError.new(@cask, conflicting_cask)
 | 
			
		||||
          end
 | 
			
		||||
          raise CaskConflictError.new(@cask, conflicting_cask) if conflicting_cask.installed?
 | 
			
		||||
        rescue CaskUnavailableError
 | 
			
		||||
          next # Ignore conflicting Casks that do not exist.
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
@ -9,17 +9,13 @@ module Cask
 | 
			
		||||
    def metadata_versioned_path(version: self.version)
 | 
			
		||||
      cask_version = (version || :unknown).to_s
 | 
			
		||||
 | 
			
		||||
      if cask_version.empty?
 | 
			
		||||
        raise CaskError, "Cannot create metadata path with empty version."
 | 
			
		||||
      end
 | 
			
		||||
      raise CaskError, "Cannot create metadata path with empty version." if cask_version.empty?
 | 
			
		||||
 | 
			
		||||
      metadata_master_container_path.join(cask_version)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def metadata_timestamped_path(version: self.version, timestamp: :latest, create: false)
 | 
			
		||||
      if create && timestamp == :latest
 | 
			
		||||
        raise CaskError, "Cannot create metadata path when timestamp is :latest."
 | 
			
		||||
      end
 | 
			
		||||
      raise CaskError, "Cannot create metadata path when timestamp is :latest." if create && timestamp == :latest
 | 
			
		||||
 | 
			
		||||
      path = if timestamp == :latest
 | 
			
		||||
        Pathname.glob(metadata_versioned_path(version: version).join("*")).max
 | 
			
		||||
@ -37,9 +33,7 @@ module Cask
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def metadata_subdir(leaf, version: self.version, timestamp: :latest, create: false)
 | 
			
		||||
      if create && timestamp == :latest
 | 
			
		||||
        raise CaskError, "Cannot create metadata subdir when timestamp is :latest."
 | 
			
		||||
      end
 | 
			
		||||
      raise CaskError, "Cannot create metadata subdir when timestamp is :latest." if create && timestamp == :latest
 | 
			
		||||
 | 
			
		||||
      unless leaf.respond_to?(:empty?) && !leaf.empty?
 | 
			
		||||
        raise CaskError, "Cannot create metadata subdir for empty leaf."
 | 
			
		||||
 | 
			
		||||
@ -47,12 +47,8 @@ class Caveats
 | 
			
		||||
 | 
			
		||||
        If you need to have #{f.name} first in your PATH run:
 | 
			
		||||
      EOS
 | 
			
		||||
      if f.bin.directory?
 | 
			
		||||
        s << "  #{Utils::Shell.prepend_path_in_profile(f.opt_bin.to_s)}\n"
 | 
			
		||||
      end
 | 
			
		||||
      if f.sbin.directory?
 | 
			
		||||
        s << "  #{Utils::Shell.prepend_path_in_profile(f.opt_sbin.to_s)}\n"
 | 
			
		||||
      end
 | 
			
		||||
      s << "  #{Utils::Shell.prepend_path_in_profile(f.opt_bin.to_s)}\n" if f.bin.directory?
 | 
			
		||||
      s << "  #{Utils::Shell.prepend_path_in_profile(f.opt_sbin.to_s)}\n" if f.sbin.directory?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if f.lib.directory? || f.include.directory?
 | 
			
		||||
@ -61,13 +57,9 @@ class Caveats
 | 
			
		||||
        For compilers to find #{f.name} you may need to set:
 | 
			
		||||
      EOS
 | 
			
		||||
 | 
			
		||||
      if f.lib.directory?
 | 
			
		||||
        s << "  #{Utils::Shell.export_value("LDFLAGS", "-L#{f.opt_lib}")}\n"
 | 
			
		||||
      end
 | 
			
		||||
      s << "  #{Utils::Shell.export_value("LDFLAGS", "-L#{f.opt_lib}")}\n" if f.lib.directory?
 | 
			
		||||
 | 
			
		||||
      if f.include.directory?
 | 
			
		||||
        s << "  #{Utils::Shell.export_value("CPPFLAGS", "-I#{f.opt_include}")}\n"
 | 
			
		||||
      end
 | 
			
		||||
      s << "  #{Utils::Shell.export_value("CPPFLAGS", "-I#{f.opt_include}")}\n" if f.include.directory?
 | 
			
		||||
 | 
			
		||||
      if which("pkg-config", ENV["HOMEBREW_PATH"]) &&
 | 
			
		||||
         ((f.lib/"pkgconfig").directory? || (f.share/"pkgconfig").directory?)
 | 
			
		||||
 | 
			
		||||
@ -25,9 +25,7 @@ class Cleaner
 | 
			
		||||
 | 
			
		||||
    # Get rid of any info 'dir' files, so they don't conflict at the link stage
 | 
			
		||||
    info_dir_file = @f.info + "dir"
 | 
			
		||||
    if info_dir_file.file? && !@f.skip_clean?(info_dir_file)
 | 
			
		||||
      observe_file_removal info_dir_file
 | 
			
		||||
    end
 | 
			
		||||
    observe_file_removal info_dir_file if info_dir_file.file? && !@f.skip_clean?(info_dir_file)
 | 
			
		||||
 | 
			
		||||
    prune
 | 
			
		||||
  end
 | 
			
		||||
@ -111,9 +109,7 @@ class Cleaner
 | 
			
		||||
        end
 | 
			
		||||
        if ARGV.debug?
 | 
			
		||||
          old_perms = path.stat.mode & 0777
 | 
			
		||||
          if perms != old_perms
 | 
			
		||||
            puts "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}"
 | 
			
		||||
          end
 | 
			
		||||
          puts "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}" if perms != old_perms
 | 
			
		||||
        end
 | 
			
		||||
        path.chmod perms
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -120,9 +120,7 @@ module CleanupRefinement
 | 
			
		||||
        return false
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      unless basename.to_s.match?(/\A#{Regexp.escape(name)}\-\-#{Regexp.escape(cask.version)}\b/)
 | 
			
		||||
        return true
 | 
			
		||||
      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)
 | 
			
		||||
 | 
			
		||||
@ -205,6 +203,7 @@ module Homebrew
 | 
			
		||||
        # avoid having to try to do a `brew install` when we've just deleted
 | 
			
		||||
        # the running Ruby process...
 | 
			
		||||
        return if periodic
 | 
			
		||||
 | 
			
		||||
        cleanup_portable_ruby
 | 
			
		||||
      else
 | 
			
		||||
        args.each do |arg|
 | 
			
		||||
@ -253,6 +252,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
    def cleanup_logs
 | 
			
		||||
      return unless HOMEBREW_LOGS.directory?
 | 
			
		||||
 | 
			
		||||
      logs_days = if days > CLEANUP_DEFAULT_DAYS
 | 
			
		||||
        CLEANUP_DEFAULT_DAYS
 | 
			
		||||
      else
 | 
			
		||||
@ -334,9 +334,7 @@ module Homebrew
 | 
			
		||||
    def cleanup_lockfiles(*lockfiles)
 | 
			
		||||
      return if dry_run?
 | 
			
		||||
 | 
			
		||||
      if lockfiles.empty? && HOMEBREW_LOCKS.directory?
 | 
			
		||||
        lockfiles = HOMEBREW_LOCKS.children.select(&:file?)
 | 
			
		||||
      end
 | 
			
		||||
      lockfiles = HOMEBREW_LOCKS.children.select(&:file?) if lockfiles.empty? && HOMEBREW_LOCKS.directory?
 | 
			
		||||
 | 
			
		||||
      lockfiles.each do |file|
 | 
			
		||||
        next unless file.readable?
 | 
			
		||||
@ -368,6 +366,7 @@ module Homebrew
 | 
			
		||||
      portable_ruby_glob = "#{portable_ruby_path}/*.*"
 | 
			
		||||
      Pathname.glob(portable_ruby_glob).each do |path|
 | 
			
		||||
        next if !use_system_ruby && portable_ruby_version == path.basename.to_s
 | 
			
		||||
 | 
			
		||||
        if dry_run?
 | 
			
		||||
          puts "Would remove: #{path} (#{path.abv})"
 | 
			
		||||
        else
 | 
			
		||||
 | 
			
		||||
@ -154,6 +154,7 @@ module Homebrew
 | 
			
		||||
      def formula_options
 | 
			
		||||
        ARGV.formulae.each do |f|
 | 
			
		||||
          next if f.options.empty?
 | 
			
		||||
 | 
			
		||||
          f.options.each do |o|
 | 
			
		||||
            name = o.flag
 | 
			
		||||
            description = "`#{f.name}`: #{o.description}"
 | 
			
		||||
@ -220,9 +221,7 @@ module Homebrew
 | 
			
		||||
          if :mandatory.equal?(constraint_type) && primary_passed && !secondary_passed
 | 
			
		||||
            raise OptionConstraintError.new(primary, secondary)
 | 
			
		||||
          end
 | 
			
		||||
          if secondary_passed && !primary_passed
 | 
			
		||||
            raise OptionConstraintError.new(primary, secondary, missing: true)
 | 
			
		||||
          end
 | 
			
		||||
          raise OptionConstraintError.new(primary, secondary, missing: true) if secondary_passed && !primary_passed
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -240,6 +239,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
          select_cli_arg = violations.count - env_var_options.count == 1
 | 
			
		||||
          raise OptionConflictError, violations.map(&method(:name_to_option)) unless select_cli_arg
 | 
			
		||||
 | 
			
		||||
          env_var_options.each(&method(:disable_switch))
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,7 @@ module Homebrew
 | 
			
		||||
  def config
 | 
			
		||||
    config_args.parse
 | 
			
		||||
    raise UsageError unless args.remaining.empty?
 | 
			
		||||
 | 
			
		||||
    SystemConfig.dump_verbose_config
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -200,9 +200,7 @@ module Homebrew
 | 
			
		||||
        "│   "
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if dep.is_a? Dependency
 | 
			
		||||
        recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_addition, true)
 | 
			
		||||
      end
 | 
			
		||||
      recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_addition, true) if dep.is_a? Dependency
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @dep_stack.pop
 | 
			
		||||
 | 
			
		||||
@ -73,9 +73,7 @@ module Homebrew
 | 
			
		||||
    end
 | 
			
		||||
    url = create_gist(files, descr)
 | 
			
		||||
 | 
			
		||||
    if args.new_issue?
 | 
			
		||||
      url = create_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url)
 | 
			
		||||
    end
 | 
			
		||||
    url = create_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url) if args.new_issue?
 | 
			
		||||
 | 
			
		||||
    puts url if url
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -51,6 +51,7 @@ module Homebrew
 | 
			
		||||
    info_args.parse
 | 
			
		||||
    if args.json
 | 
			
		||||
      raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
 | 
			
		||||
 | 
			
		||||
      print_json
 | 
			
		||||
    elsif args.github?
 | 
			
		||||
      exec_browser(*ARGV.formulae.map { |f| github_info(f) })
 | 
			
		||||
@ -310,9 +311,7 @@ module Homebrew
 | 
			
		||||
  def output_analytics(filter: nil)
 | 
			
		||||
    days = args.days || "30"
 | 
			
		||||
    valid_days = %w[30 90 365]
 | 
			
		||||
    unless valid_days.include?(days)
 | 
			
		||||
      raise ArgumentError("Days must be one of #{valid_days.join(", ")}!")
 | 
			
		||||
    end
 | 
			
		||||
    raise ArgumentError("Days must be one of #{valid_days.join(", ")}!") unless valid_days.include?(days)
 | 
			
		||||
 | 
			
		||||
    category = args.category || "install"
 | 
			
		||||
    valid_categories = %w[install install-on-request build-error os-version]
 | 
			
		||||
 | 
			
		||||
@ -94,9 +94,7 @@ module Homebrew
 | 
			
		||||
    unless args.force?
 | 
			
		||||
      ARGV.named.each do |name|
 | 
			
		||||
        next if File.exist?(name)
 | 
			
		||||
        if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
 | 
			
		||||
          next
 | 
			
		||||
        end
 | 
			
		||||
        next if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
 | 
			
		||||
 | 
			
		||||
        tap = Tap.fetch(Regexp.last_match(1), Regexp.last_match(2))
 | 
			
		||||
        tap.install unless tap.installed?
 | 
			
		||||
@ -143,14 +141,10 @@ module Homebrew
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      # --HEAD, fail with no head defined
 | 
			
		||||
      if args.head? && f.head.nil?
 | 
			
		||||
        raise "No head is defined for #{f.full_name}"
 | 
			
		||||
      end
 | 
			
		||||
      raise "No head is defined for #{f.full_name}" if args.head? && f.head.nil?
 | 
			
		||||
 | 
			
		||||
      # --devel, fail with no devel defined
 | 
			
		||||
      if args.devel? && f.devel.nil?
 | 
			
		||||
        raise "No devel block is defined for #{f.full_name}"
 | 
			
		||||
      end
 | 
			
		||||
      raise "No devel block is defined for #{f.full_name}" if args.devel? && f.devel.nil?
 | 
			
		||||
 | 
			
		||||
      installed_head_version = f.latest_head_version
 | 
			
		||||
      if installed_head_version &&
 | 
			
		||||
 | 
			
		||||
@ -133,9 +133,7 @@ module Homebrew
 | 
			
		||||
      pinned_versions = {}
 | 
			
		||||
      names.sort.each do |d|
 | 
			
		||||
        keg_pin = (HOMEBREW_PINNED_KEGS/d.basename.to_s)
 | 
			
		||||
        if keg_pin.exist? || keg_pin.symlink?
 | 
			
		||||
          pinned_versions[d] = keg_pin.readlink.basename.to_s
 | 
			
		||||
        end
 | 
			
		||||
        pinned_versions[d] = keg_pin.readlink.basename.to_s if keg_pin.exist? || keg_pin.symlink?
 | 
			
		||||
      end
 | 
			
		||||
      pinned_versions.each do |d, version|
 | 
			
		||||
        puts d.basename.to_s.concat(args.versions? ? " #{version}" : "")
 | 
			
		||||
 | 
			
		||||
@ -75,9 +75,7 @@ module Homebrew
 | 
			
		||||
        puts "  #{Formatter.url("https://github.com/Homebrew/brew#donations")}\n"
 | 
			
		||||
 | 
			
		||||
        # Consider the message possibly missed if not a TTY.
 | 
			
		||||
        if $stdout.tty?
 | 
			
		||||
          safe_system "git", "config", "--local", "--replace-all", "homebrew.donationmessage", "true"
 | 
			
		||||
        end
 | 
			
		||||
        safe_system "git", "config", "--local", "--replace-all", "homebrew.donationmessage", "true" if $stdout.tty?
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -88,9 +86,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
    initial_revision = ENV["HOMEBREW_UPDATE_BEFORE"].to_s
 | 
			
		||||
    current_revision = ENV["HOMEBREW_UPDATE_AFTER"].to_s
 | 
			
		||||
    if initial_revision.empty? || current_revision.empty?
 | 
			
		||||
      odie "update-report should not be called directly!"
 | 
			
		||||
    end
 | 
			
		||||
    odie "update-report should not be called directly!" if initial_revision.empty? || current_revision.empty?
 | 
			
		||||
 | 
			
		||||
    if initial_revision != current_revision
 | 
			
		||||
      update_preinstall_header
 | 
			
		||||
@ -121,9 +117,7 @@ module Homebrew
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if !updated
 | 
			
		||||
      if !ARGV.include?("--preinstall") && !ENV["HOMEBREW_UPDATE_FAILED"]
 | 
			
		||||
        puts "Already up-to-date."
 | 
			
		||||
      end
 | 
			
		||||
      puts "Already up-to-date." if !ARGV.include?("--preinstall") && !ENV["HOMEBREW_UPDATE_FAILED"]
 | 
			
		||||
    else
 | 
			
		||||
      if hub.empty?
 | 
			
		||||
        puts "No changes to formulae."
 | 
			
		||||
 | 
			
		||||
@ -18,9 +18,7 @@ class CompilerFailure
 | 
			
		||||
  def version(val = nil)
 | 
			
		||||
    if val
 | 
			
		||||
      @version = Version.parse(val.to_s)
 | 
			
		||||
      if name.to_s == "clang" && val.to_i < 600
 | 
			
		||||
        odisabled "'fails_with :clang' with 'build' < 600"
 | 
			
		||||
      end
 | 
			
		||||
      odisabled "'fails_with :clang' with 'build' < 600" if name.to_s == "clang" && val.to_i < 600
 | 
			
		||||
    end
 | 
			
		||||
    @version
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,4 @@
 | 
			
		||||
unless ENV["HOMEBREW_BREW_FILE"]
 | 
			
		||||
  raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
 | 
			
		||||
end
 | 
			
		||||
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
 | 
			
		||||
 | 
			
		||||
# Path to `bin/brew` main executable in `HOMEBREW_PREFIX`
 | 
			
		||||
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"])
 | 
			
		||||
@ -8,9 +6,8 @@ HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"])
 | 
			
		||||
class MissingEnvironmentVariables < RuntimeError; end
 | 
			
		||||
 | 
			
		||||
def get_env_or_raise(env)
 | 
			
		||||
  unless ENV[env]
 | 
			
		||||
    raise MissingEnvironmentVariables, "#{env} was not exported!"
 | 
			
		||||
  end
 | 
			
		||||
  raise MissingEnvironmentVariables, "#{env} was not exported!" unless ENV[env]
 | 
			
		||||
 | 
			
		||||
  ENV[env]
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -13,9 +13,7 @@ class CxxStdlib
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.create(type, compiler)
 | 
			
		||||
    if type && ![:libstdcxx, :libcxx].include?(type)
 | 
			
		||||
      raise ArgumentError, "Invalid C++ stdlib type: #{type}"
 | 
			
		||||
    end
 | 
			
		||||
    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)
 | 
			
		||||
@ -60,9 +58,7 @@ class CxxStdlib
 | 
			
		||||
      next if dep.build?
 | 
			
		||||
 | 
			
		||||
      dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib
 | 
			
		||||
      unless compatible_with? dep_stdlib
 | 
			
		||||
        raise CompatibilityError.new(formula, dep, dep_stdlib)
 | 
			
		||||
      end
 | 
			
		||||
      raise CompatibilityError.new(formula, dep, dep_stdlib) unless compatible_with? dep_stdlib
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -95,21 +95,15 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
    formula.send("recursive_#{type}") do |dependent, dep|
 | 
			
		||||
      if dep.recommended?
 | 
			
		||||
        if ignores.include?("recommended?") || dependent.build.without?(dep)
 | 
			
		||||
          klass.prune
 | 
			
		||||
        end
 | 
			
		||||
        klass.prune if ignores.include?("recommended?") || dependent.build.without?(dep)
 | 
			
		||||
      elsif dep.test?
 | 
			
		||||
        if includes.include?("test?")
 | 
			
		||||
          if type == :dependencies
 | 
			
		||||
            Dependency.keep_but_prune_recursive_deps
 | 
			
		||||
          end
 | 
			
		||||
          Dependency.keep_but_prune_recursive_deps if type == :dependencies
 | 
			
		||||
        else
 | 
			
		||||
          klass.prune
 | 
			
		||||
        end
 | 
			
		||||
      elsif dep.optional?
 | 
			
		||||
        if !includes.include?("optional?") && !dependent.build.with?(dep)
 | 
			
		||||
          klass.prune
 | 
			
		||||
        end
 | 
			
		||||
        klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
 | 
			
		||||
      elsif dep.build?
 | 
			
		||||
        klass.prune unless includes.include?("build?")
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -134,9 +134,7 @@ class DependencyCollector
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def parse_class_spec(spec, tags)
 | 
			
		||||
    unless spec < Requirement
 | 
			
		||||
      raise TypeError, "#{spec.inspect} is not a Requirement subclass"
 | 
			
		||||
    end
 | 
			
		||||
    raise TypeError, "#{spec.inspect} is not a Requirement subclass" unless spec < Requirement
 | 
			
		||||
 | 
			
		||||
    spec.new(tags)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -136,9 +136,7 @@ module Homebrew
 | 
			
		||||
    created_pr_comment = false
 | 
			
		||||
    if new_formula && !new_formula_problem_lines.empty?
 | 
			
		||||
      begin
 | 
			
		||||
        if GitHub.create_issue_comment(new_formula_problem_lines.join("\n"))
 | 
			
		||||
          created_pr_comment = true
 | 
			
		||||
        end
 | 
			
		||||
        created_pr_comment = true if GitHub.create_issue_comment(new_formula_problem_lines.join("\n"))
 | 
			
		||||
      rescue *GitHub.api_errors => e
 | 
			
		||||
        opoo "Unable to create issue comment: #{e.message}"
 | 
			
		||||
      end
 | 
			
		||||
@ -154,9 +152,7 @@ module Homebrew
 | 
			
		||||
    formula_plural = "#{formula_count} #{"formula".pluralize(formula_count)}"
 | 
			
		||||
    corrected_problem_plural = "#{corrected_problem_count} #{"problem".pluralize(corrected_problem_count)}"
 | 
			
		||||
    errors_summary = "#{problem_plural} in #{formula_plural} detected"
 | 
			
		||||
    if corrected_problem_count.positive?
 | 
			
		||||
      errors_summary += ", #{corrected_problem_plural} corrected"
 | 
			
		||||
    end
 | 
			
		||||
    errors_summary += ", #{corrected_problem_plural} corrected" if corrected_problem_count.positive?
 | 
			
		||||
 | 
			
		||||
    if problem_count.positive? ||
 | 
			
		||||
       (new_formula_problem_count.positive? && !created_pr_comment)
 | 
			
		||||
@ -263,9 +259,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      problem "'DATA' was found, but no '__END__'" if text.data? && !text.end?
 | 
			
		||||
 | 
			
		||||
      if text.end? && !text.data?
 | 
			
		||||
        problem "'__END__' was found, but 'DATA' is not used"
 | 
			
		||||
      end
 | 
			
		||||
      problem "'__END__' was found, but 'DATA' is not used" if text.end? && !text.data?
 | 
			
		||||
 | 
			
		||||
      if text =~ /inreplace [^\n]* do [^\n]*\n[^\n]*\.gsub![^\n]*\n\ *end/m
 | 
			
		||||
        problem "'inreplace ... do' was used for a single substitution (use the non-block form instead)."
 | 
			
		||||
@ -344,9 +338,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      name = formula.name
 | 
			
		||||
 | 
			
		||||
      if MissingFormula.blacklisted_reason(name)
 | 
			
		||||
        problem "'#{name}' is blacklisted."
 | 
			
		||||
      end
 | 
			
		||||
      problem "'#{name}' is blacklisted." if MissingFormula.blacklisted_reason(name)
 | 
			
		||||
 | 
			
		||||
      if Formula.aliases.include? name
 | 
			
		||||
        problem "Formula name conflicts with existing aliases."
 | 
			
		||||
@ -418,13 +410,9 @@ module Homebrew
 | 
			
		||||
            problem "Dependency #{dep} does not define option #{opt.name.inspect}"
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          if dep.name == "git"
 | 
			
		||||
            problem "Don't use git as a dependency (it's always available)"
 | 
			
		||||
          end
 | 
			
		||||
          problem "Don't use git as a dependency (it's always available)" if dep.name == "git"
 | 
			
		||||
 | 
			
		||||
          if dep.tags.include?(:run)
 | 
			
		||||
            problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op."
 | 
			
		||||
          end
 | 
			
		||||
          problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op." if dep.tags.include?(:run)
 | 
			
		||||
 | 
			
		||||
          next unless @core_tap
 | 
			
		||||
 | 
			
		||||
@ -565,11 +553,10 @@ module Homebrew
 | 
			
		||||
      return unless formula.bottle_disabled?
 | 
			
		||||
      return if formula.bottle_unneeded?
 | 
			
		||||
 | 
			
		||||
      unless formula.bottle_disable_reason.valid?
 | 
			
		||||
        problem "Unrecognized bottle modifier"
 | 
			
		||||
      end
 | 
			
		||||
      problem "Unrecognized bottle modifier" unless formula.bottle_disable_reason.valid?
 | 
			
		||||
 | 
			
		||||
      return unless @core_tap
 | 
			
		||||
 | 
			
		||||
      problem "Formulae should not use `bottle :disabled`"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -635,9 +622,7 @@ module Homebrew
 | 
			
		||||
        next unless spec = formula.send(name.downcase)
 | 
			
		||||
 | 
			
		||||
        version = spec.version
 | 
			
		||||
        if version.to_s !~ /\d/
 | 
			
		||||
          problem "#{name}: version (#{version}) is set to a string without a digit"
 | 
			
		||||
        end
 | 
			
		||||
        problem "#{name}: version (#{version}) is set to a string without a digit" if version.to_s !~ /\d/
 | 
			
		||||
        if version.to_s.start_with?("HEAD")
 | 
			
		||||
          problem "#{name}: non-HEAD version name (#{version}) should not begin with HEAD"
 | 
			
		||||
        end
 | 
			
		||||
@ -733,9 +718,7 @@ module Homebrew
 | 
			
		||||
        version = Version.parse(stable.url)
 | 
			
		||||
        if version >= Version.create("1.0")
 | 
			
		||||
          _, minor_version, = version.to_s.split(".", 3).map(&:to_i)
 | 
			
		||||
          if minor_version.odd?
 | 
			
		||||
            problem "#{stable.version} is a development release"
 | 
			
		||||
          end
 | 
			
		||||
          problem "#{stable.version} is a development release" if minor_version.odd?
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
@ -875,9 +858,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      return unless @strict
 | 
			
		||||
 | 
			
		||||
      if line.include?("env :userpaths")
 | 
			
		||||
        problem "`env :userpaths` in formulae is deprecated"
 | 
			
		||||
      end
 | 
			
		||||
      problem "`env :userpaths` in formulae is deprecated" if line.include?("env :userpaths")
 | 
			
		||||
 | 
			
		||||
      if line =~ /system ((["'])[^"' ]*(?:\s[^"' ]*)+\2)/
 | 
			
		||||
        bad_system = Regexp.last_match(1)
 | 
			
		||||
@ -904,6 +885,7 @@ module Homebrew
 | 
			
		||||
      return unless @core_tap
 | 
			
		||||
 | 
			
		||||
      return unless line.include?("env :std")
 | 
			
		||||
 | 
			
		||||
      problem "`env :std` in `core` formulae is deprecated"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -954,9 +936,7 @@ module Homebrew
 | 
			
		||||
    def audit
 | 
			
		||||
      only_audits = @only
 | 
			
		||||
      except_audits = @except
 | 
			
		||||
      if only_audits && except_audits
 | 
			
		||||
        odie "--only and --except cannot be used simultaneously!"
 | 
			
		||||
      end
 | 
			
		||||
      odie "--only and --except cannot be used simultaneously!" if only_audits && except_audits
 | 
			
		||||
 | 
			
		||||
      methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name|
 | 
			
		||||
        name = audit_method_name.gsub(/^audit_/, "")
 | 
			
		||||
@ -1027,9 +1007,7 @@ module Homebrew
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if version.to_s.start_with?("v")
 | 
			
		||||
        problem "version #{version} should not have a leading 'v'"
 | 
			
		||||
      end
 | 
			
		||||
      problem "version #{version} should not have a leading 'v'" if version.to_s.start_with?("v")
 | 
			
		||||
 | 
			
		||||
      return unless version.to_s =~ /_\d+$/
 | 
			
		||||
 | 
			
		||||
@ -1044,9 +1022,7 @@ module Homebrew
 | 
			
		||||
      url_strategy = DownloadStrategyDetector.detect(url)
 | 
			
		||||
 | 
			
		||||
      if using == :git || url_strategy == GitDownloadStrategy
 | 
			
		||||
        if specs[:tag] && !specs[:revision]
 | 
			
		||||
          problem "Git should specify :revision when a :tag is specified."
 | 
			
		||||
        end
 | 
			
		||||
        problem "Git should specify :revision when a :tag is specified." if specs[:tag] && !specs[:revision]
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      return unless using
 | 
			
		||||
@ -1101,16 +1077,12 @@ module Homebrew
 | 
			
		||||
            problem http_content_problem
 | 
			
		||||
          end
 | 
			
		||||
        elsif strategy <= GitDownloadStrategy
 | 
			
		||||
          unless Utils.git_remote_exists? url
 | 
			
		||||
            problem "The URL #{url} is not a valid git URL"
 | 
			
		||||
          end
 | 
			
		||||
          problem "The URL #{url} is not a valid git URL" unless Utils.git_remote_exists? url
 | 
			
		||||
        elsif strategy <= SubversionDownloadStrategy
 | 
			
		||||
          next unless DevelopmentTools.subversion_handles_most_https_certificates?
 | 
			
		||||
          next unless Utils.svn_available?
 | 
			
		||||
 | 
			
		||||
          unless Utils.svn_remote_exists? url
 | 
			
		||||
            problem "The URL #{url} is not a valid svn URL"
 | 
			
		||||
          end
 | 
			
		||||
          problem "The URL #{url} is not a valid svn URL" unless Utils.svn_remote_exists? url
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -205,14 +205,10 @@ module Homebrew
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def bottle_formula(f)
 | 
			
		||||
    unless f.installed?
 | 
			
		||||
      return ofail "Formula not installed or up-to-date: #{f.full_name}"
 | 
			
		||||
    end
 | 
			
		||||
    return ofail "Formula not installed or up-to-date: #{f.full_name}" unless f.installed?
 | 
			
		||||
 | 
			
		||||
    unless tap = f.tap
 | 
			
		||||
      unless args.force_core_tap?
 | 
			
		||||
        return ofail "Formula not from core or any installed taps: #{f.full_name}"
 | 
			
		||||
      end
 | 
			
		||||
      return ofail "Formula not from core or any installed taps: #{f.full_name}" unless args.force_core_tap?
 | 
			
		||||
 | 
			
		||||
      tap = CoreTap.instance
 | 
			
		||||
    end
 | 
			
		||||
@ -223,9 +219,7 @@ module Homebrew
 | 
			
		||||
      return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless Utils::Bottles.built_as? f
 | 
			
		||||
      return ofail "Formula not installed with '--build-bottle': #{f.full_name}"
 | 
			
		||||
    end
 | 
			
		||||
    return ofail "Formula not installed with '--build-bottle': #{f.full_name}" unless Utils::Bottles.built_as? f
 | 
			
		||||
 | 
			
		||||
    return ofail "Formula has no stable version: #{f.full_name}" unless f.stable
 | 
			
		||||
 | 
			
		||||
@ -265,9 +259,7 @@ module Homebrew
 | 
			
		||||
      begin
 | 
			
		||||
        keg.delete_pyc_files!
 | 
			
		||||
 | 
			
		||||
        unless args.skip_relocation?
 | 
			
		||||
          changed_files = keg.replace_locations_with_placeholders
 | 
			
		||||
        end
 | 
			
		||||
        changed_files = keg.replace_locations_with_placeholders unless args.skip_relocation?
 | 
			
		||||
 | 
			
		||||
        Tab.clear_cache
 | 
			
		||||
        tab = Tab.for_keg(keg)
 | 
			
		||||
@ -300,9 +292,7 @@ module Homebrew
 | 
			
		||||
          mv "#{relocatable_tar_path}.gz", bottle_path
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        if bottle_path.size > 1 * 1024 * 1024
 | 
			
		||||
          ohai "Detecting if #{filename} is relocatable..."
 | 
			
		||||
        end
 | 
			
		||||
        ohai "Detecting if #{filename} is relocatable..." if bottle_path.size > 1 * 1024 * 1024
 | 
			
		||||
 | 
			
		||||
        if Homebrew.default_prefix?(prefix)
 | 
			
		||||
          prefix_check = File.join(prefix, "opt")
 | 
			
		||||
@ -344,9 +334,7 @@ module Homebrew
 | 
			
		||||
      ensure
 | 
			
		||||
        ignore_interrupts do
 | 
			
		||||
          original_tab&.write
 | 
			
		||||
          unless args.skip_relocation?
 | 
			
		||||
            keg.replace_placeholders_with_locations changed_files
 | 
			
		||||
          end
 | 
			
		||||
          keg.replace_placeholders_with_locations changed_files unless args.skip_relocation?
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
@ -510,9 +498,7 @@ module Homebrew
 | 
			
		||||
            string = s.sub!(/  bottle do.+?end\n/m, output)
 | 
			
		||||
            odie "Bottle block update failed!" unless string
 | 
			
		||||
          else
 | 
			
		||||
            if args.keep_old?
 | 
			
		||||
              odie "--keep-old was passed but there was no existing bottle block!"
 | 
			
		||||
            end
 | 
			
		||||
            odie "--keep-old was passed but there was no existing bottle block!" if args.keep_old?
 | 
			
		||||
            puts output
 | 
			
		||||
            update_or_add = "add"
 | 
			
		||||
            if s.include? "stable do"
 | 
			
		||||
 | 
			
		||||
@ -331,6 +331,7 @@ module Homebrew
 | 
			
		||||
          username = response.fetch("owner").fetch("login")
 | 
			
		||||
        rescue GitHub::AuthenticationFailedError => e
 | 
			
		||||
          raise unless e.github_message =~ /forking is disabled/
 | 
			
		||||
 | 
			
		||||
          # If the repository is private, forking might be disabled.
 | 
			
		||||
          # Create branches in the repository itself instead.
 | 
			
		||||
          remote_url = Utils.popen_read("git remote get-url --push origin").chomp
 | 
			
		||||
@ -380,30 +381,20 @@ module Homebrew
 | 
			
		||||
      contents = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read }
 | 
			
		||||
      contents.extend(StringInreplaceExtension)
 | 
			
		||||
      replacement_pairs.each do |old, new|
 | 
			
		||||
        unless Homebrew.args.quiet?
 | 
			
		||||
          ohai "replace #{old.inspect} with #{new.inspect}"
 | 
			
		||||
        end
 | 
			
		||||
        unless old
 | 
			
		||||
          raise "No old value for new value #{new}! Did you pass the wrong arguments?"
 | 
			
		||||
        end
 | 
			
		||||
        ohai "replace #{old.inspect} with #{new.inspect}" unless Homebrew.args.quiet?
 | 
			
		||||
        raise "No old value for new value #{new}! Did you pass the wrong arguments?" unless old
 | 
			
		||||
 | 
			
		||||
        contents.gsub!(old, new)
 | 
			
		||||
      end
 | 
			
		||||
      unless contents.errors.empty?
 | 
			
		||||
        raise Utils::InreplaceError, path => contents.errors
 | 
			
		||||
      end
 | 
			
		||||
      raise Utils::InreplaceError, path => contents.errors unless contents.errors.empty?
 | 
			
		||||
 | 
			
		||||
      path.atomic_write(contents) if args.write?
 | 
			
		||||
      contents
 | 
			
		||||
    else
 | 
			
		||||
      Utils::Inreplace.inreplace(path) do |s|
 | 
			
		||||
        replacement_pairs.each do |old, new|
 | 
			
		||||
          unless Homebrew.args.quiet?
 | 
			
		||||
            ohai "replace #{old.inspect} with #{new.inspect}"
 | 
			
		||||
          end
 | 
			
		||||
          unless old
 | 
			
		||||
            raise "No old value for new value #{new}! Did you pass the wrong arguments?"
 | 
			
		||||
          end
 | 
			
		||||
          ohai "replace #{old.inspect} with #{new.inspect}" unless Homebrew.args.quiet?
 | 
			
		||||
          raise "No old value for new value #{new}! Did you pass the wrong arguments?" unless old
 | 
			
		||||
 | 
			
		||||
          s.gsub!(old, new)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
@ -5,38 +5,28 @@ require "tap"
 | 
			
		||||
 | 
			
		||||
def with_monkey_patch
 | 
			
		||||
  BottleSpecification.class_eval do
 | 
			
		||||
    if method_defined?(:method_missing)
 | 
			
		||||
      alias_method :old_method_missing, :method_missing
 | 
			
		||||
    end
 | 
			
		||||
    alias_method :old_method_missing, :method_missing if method_defined?(:method_missing)
 | 
			
		||||
    define_method(:method_missing) { |*| }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  Module.class_eval do
 | 
			
		||||
    if method_defined?(:method_missing)
 | 
			
		||||
      alias_method :old_method_missing, :method_missing
 | 
			
		||||
    end
 | 
			
		||||
    alias_method :old_method_missing, :method_missing if method_defined?(:method_missing)
 | 
			
		||||
    define_method(:method_missing) { |*| }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  Resource.class_eval do
 | 
			
		||||
    if method_defined?(:method_missing)
 | 
			
		||||
      alias_method :old_method_missing, :method_missing
 | 
			
		||||
    end
 | 
			
		||||
    alias_method :old_method_missing, :method_missing if method_defined?(:method_missing)
 | 
			
		||||
    define_method(:method_missing) { |*| }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  DependencyCollector.class_eval do
 | 
			
		||||
    if method_defined?(:parse_symbol_spec)
 | 
			
		||||
      alias_method :old_parse_symbol_spec, :parse_symbol_spec
 | 
			
		||||
    end
 | 
			
		||||
    alias_method :old_parse_symbol_spec, :parse_symbol_spec if method_defined?(:parse_symbol_spec)
 | 
			
		||||
    define_method(:parse_symbol_spec) { |*| }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  if defined?(DependencyCollector::Compat)
 | 
			
		||||
    DependencyCollector::Compat.class_eval do
 | 
			
		||||
      if method_defined?(:parse_string_spec)
 | 
			
		||||
        alias_method :old_parse_string_spec, :parse_string_spec
 | 
			
		||||
      end
 | 
			
		||||
      alias_method :old_parse_string_spec, :parse_string_spec if method_defined?(:parse_string_spec)
 | 
			
		||||
      define_method(:parse_string_spec) { |*| }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -34,9 +34,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
    raise UsageError unless ARGV.named.empty?
 | 
			
		||||
 | 
			
		||||
    if args.link?
 | 
			
		||||
      odie "`brew man --link` is now done automatically by `brew update`."
 | 
			
		||||
    end
 | 
			
		||||
    odie "`brew man --link` is now done automatically by `brew update`." if args.link?
 | 
			
		||||
 | 
			
		||||
    regenerate_man_pages
 | 
			
		||||
 | 
			
		||||
@ -157,9 +155,11 @@ module Homebrew
 | 
			
		||||
      cmd_man_page_lines = begin
 | 
			
		||||
        cmd_parser = Homebrew.send(cmd_args_method_name)
 | 
			
		||||
        next if cmd_parser.hide_from_man_page
 | 
			
		||||
 | 
			
		||||
        cmd_parser_manpage_lines(cmd_parser).join
 | 
			
		||||
      rescue NoMethodError => e
 | 
			
		||||
        raise if e.name != cmd_args_method_name
 | 
			
		||||
 | 
			
		||||
        nil
 | 
			
		||||
      end
 | 
			
		||||
      cmd_man_page_lines ||= cmd_comment_manpage_lines(cmd_path)
 | 
			
		||||
@ -178,6 +178,7 @@ module Homebrew
 | 
			
		||||
    lines = [format_usage_banner(cmd_parser.usage_banner_text)]
 | 
			
		||||
    lines += cmd_parser.processed_options.map do |short, long, _, desc|
 | 
			
		||||
      next if !long.nil? && cmd_parser.global_option?(cmd_parser.option_to_name(long))
 | 
			
		||||
 | 
			
		||||
      generate_option_doc(short, long, desc)
 | 
			
		||||
    end.reject(&:blank?)
 | 
			
		||||
    lines
 | 
			
		||||
@ -187,11 +188,13 @@ module Homebrew
 | 
			
		||||
    comment_lines = cmd_path.read.lines.grep(/^#:/)
 | 
			
		||||
    return if comment_lines.empty?
 | 
			
		||||
    return if comment_lines.first.include?("@hide_from_man_page")
 | 
			
		||||
 | 
			
		||||
    lines = [format_usage_banner(comment_lines.first).chomp]
 | 
			
		||||
    comment_lines.slice(1..-1)
 | 
			
		||||
                 .each do |line|
 | 
			
		||||
      line = line.slice(4..-1)
 | 
			
		||||
      next unless line
 | 
			
		||||
 | 
			
		||||
      lines << line.gsub(/^ +(-+[a-z-]+) */, "* `\\1`:\n  ")
 | 
			
		||||
    end
 | 
			
		||||
    lines
 | 
			
		||||
 | 
			
		||||
@ -23,9 +23,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
    bintray_user = ENV["HOMEBREW_BINTRAY_USER"]
 | 
			
		||||
    bintray_key = ENV["HOMEBREW_BINTRAY_KEY"]
 | 
			
		||||
    if !bintray_user || !bintray_key
 | 
			
		||||
      raise "Missing HOMEBREW_BINTRAY_USER or HOMEBREW_BINTRAY_KEY variables!"
 | 
			
		||||
    end
 | 
			
		||||
    raise "Missing HOMEBREW_BINTRAY_USER or HOMEBREW_BINTRAY_KEY variables!" if !bintray_user || !bintray_key
 | 
			
		||||
 | 
			
		||||
    ARGV.formulae.each do |f|
 | 
			
		||||
      bintray_package = Utils::Bottles::Bintray.package f.name
 | 
			
		||||
 | 
			
		||||
@ -66,17 +66,11 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
    pull_args.parse
 | 
			
		||||
 | 
			
		||||
    if ARGV.named.empty?
 | 
			
		||||
      odie "This command requires at least one argument containing a URL or pull request number"
 | 
			
		||||
    end
 | 
			
		||||
    odie "This command requires at least one argument containing a URL or pull request number" if ARGV.named.empty?
 | 
			
		||||
 | 
			
		||||
    # Passthrough Git environment variables for e.g. git am
 | 
			
		||||
    if ENV["HOMEBREW_GIT_NAME"]
 | 
			
		||||
      ENV["GIT_COMMITTER_NAME"] = ENV["HOMEBREW_GIT_NAME"]
 | 
			
		||||
    end
 | 
			
		||||
    if ENV["HOMEBREW_GIT_EMAIL"]
 | 
			
		||||
      ENV["GIT_COMMITTER_EMAIL"] = ENV["HOMEBREW_GIT_EMAIL"]
 | 
			
		||||
    end
 | 
			
		||||
    ENV["GIT_COMMITTER_NAME"] = ENV["HOMEBREW_GIT_NAME"] if ENV["HOMEBREW_GIT_NAME"]
 | 
			
		||||
    ENV["GIT_COMMITTER_EMAIL"] = ENV["HOMEBREW_GIT_EMAIL"] if ENV["HOMEBREW_GIT_EMAIL"]
 | 
			
		||||
 | 
			
		||||
    # Depending on user configuration, git may try to invoke gpg.
 | 
			
		||||
    if Utils.popen_read("git config --get --bool commit.gpgsign").chomp == "true"
 | 
			
		||||
@ -123,9 +117,7 @@ module Homebrew
 | 
			
		||||
        odie "Not a GitHub pull request or commit: #{arg}"
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if !testing_job && args.bottle? && issue.nil?
 | 
			
		||||
        odie "No pull request detected!"
 | 
			
		||||
      end
 | 
			
		||||
      odie "No pull request detected!" if !testing_job && args.bottle? && issue.nil?
 | 
			
		||||
 | 
			
		||||
      if tap
 | 
			
		||||
        tap.install unless tap.installed?
 | 
			
		||||
@ -157,9 +149,7 @@ module Homebrew
 | 
			
		||||
        end
 | 
			
		||||
        odie "Can not bump if non-formula files are changed" unless patch_changes[:others].empty?
 | 
			
		||||
      end
 | 
			
		||||
      if is_bumpable
 | 
			
		||||
        old_versions = current_versions_from_info_external(patch_changes[:formulae].first)
 | 
			
		||||
      end
 | 
			
		||||
      old_versions = current_versions_from_info_external(patch_changes[:formulae].first) if is_bumpable
 | 
			
		||||
      patch_puller.apply_patch
 | 
			
		||||
 | 
			
		||||
      changed_formulae_names = []
 | 
			
		||||
@ -288,9 +278,7 @@ module Homebrew
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def publish_changed_formula_bottles(tap, changed_formulae_names)
 | 
			
		||||
    if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
 | 
			
		||||
      raise "Need to load formulae to publish them!"
 | 
			
		||||
    end
 | 
			
		||||
    raise "Need to load formulae to publish them!" if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
 | 
			
		||||
 | 
			
		||||
    published = []
 | 
			
		||||
    bintray_creds = { user: ENV["HOMEBREW_BINTRAY_USER"], key: ENV["HOMEBREW_BINTRAY_KEY"] }
 | 
			
		||||
@ -458,9 +446,7 @@ module Homebrew
 | 
			
		||||
    repo = Utils::Bottles::Bintray.repository(f.tap)
 | 
			
		||||
    package = Utils::Bottles::Bintray.package(f.name)
 | 
			
		||||
    info = FormulaInfoFromJson.lookup(f.full_name)
 | 
			
		||||
    if info.nil?
 | 
			
		||||
      raise "Failed publishing bottle: failed reading formula info for #{f.full_name}"
 | 
			
		||||
    end
 | 
			
		||||
    raise "Failed publishing bottle: failed reading formula info for #{f.full_name}" if info.nil?
 | 
			
		||||
 | 
			
		||||
    unless info.bottle_info_any
 | 
			
		||||
      opoo "No bottle defined in formula #{package}"
 | 
			
		||||
@ -562,9 +548,7 @@ module Homebrew
 | 
			
		||||
  def verify_bintray_published(formulae_names)
 | 
			
		||||
    return if formulae_names.empty?
 | 
			
		||||
 | 
			
		||||
    if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
 | 
			
		||||
      raise "Need to load formulae to verify their publication!"
 | 
			
		||||
    end
 | 
			
		||||
    raise "Need to load formulae to verify their publication!" if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
 | 
			
		||||
 | 
			
		||||
    ohai "Verifying bottles published on Bintray"
 | 
			
		||||
    formulae = formulae_names.map { |n| Formula[n] }
 | 
			
		||||
@ -605,9 +589,7 @@ module Homebrew
 | 
			
		||||
              raise "Failed to find published #{f} bottle at #{url} (#{res.code} #{res.message})!"
 | 
			
		||||
            end
 | 
			
		||||
 | 
			
		||||
            if retry_count >= max_retries
 | 
			
		||||
              raise "Failed to find published #{f} bottle at #{url}!"
 | 
			
		||||
            end
 | 
			
		||||
            raise "Failed to find published #{f} bottle at #{url}!" if retry_count >= max_retries
 | 
			
		||||
 | 
			
		||||
            print(wrote_dots ? "." : "Waiting on Bintray.")
 | 
			
		||||
            wrote_dots = true
 | 
			
		||||
@ -630,9 +612,7 @@ module Homebrew
 | 
			
		||||
            curl_download url, to: filename
 | 
			
		||||
            break
 | 
			
		||||
          rescue
 | 
			
		||||
            if retry_count >= max_curl_retries
 | 
			
		||||
              raise "Failed to download #{f} bottle from #{url}!"
 | 
			
		||||
            end
 | 
			
		||||
            raise "Failed to download #{f} bottle from #{url}!" if retry_count >= max_curl_retries
 | 
			
		||||
 | 
			
		||||
            puts "curl download failed; retrying in #{curl_retry_delay_seconds} sec"
 | 
			
		||||
            sleep curl_retry_delay_seconds
 | 
			
		||||
 | 
			
		||||
@ -278,9 +278,7 @@ module Homebrew
 | 
			
		||||
          next unless d.directory?
 | 
			
		||||
 | 
			
		||||
          d.find do |path|
 | 
			
		||||
            if path.symlink? && !path.resolved_path_exists?
 | 
			
		||||
              broken_symlinks << path
 | 
			
		||||
            end
 | 
			
		||||
            broken_symlinks << path if path.symlink? && !path.resolved_path_exists?
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
        return if broken_symlinks.empty?
 | 
			
		||||
 | 
			
		||||
@ -375,9 +375,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
 | 
			
		||||
 | 
			
		||||
      if filename_with_encoding = content_disposition.parameters["filename*"]
 | 
			
		||||
        encoding, encoded_filename = filename_with_encoding.split("''", 2)
 | 
			
		||||
        if encoding && encoded_filename
 | 
			
		||||
          filename = URI.decode_www_form_component(encoded_filename).encode(encoding)
 | 
			
		||||
        end
 | 
			
		||||
        filename = URI.decode_www_form_component(encoded_filename).encode(encoding) if encoding && encoded_filename
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      filename || content_disposition.filename
 | 
			
		||||
 | 
			
		||||
@ -110,9 +110,7 @@ module Superenv
 | 
			
		||||
    path.append("/usr/bin", "/bin", "/usr/sbin", "/sbin")
 | 
			
		||||
 | 
			
		||||
    begin
 | 
			
		||||
      if homebrew_cc =~ GNU_GCC_REGEXP
 | 
			
		||||
        path.append(gcc_version_formula($&).opt_bin)
 | 
			
		||||
      end
 | 
			
		||||
      path.append(gcc_version_formula($&).opt_bin) if homebrew_cc =~ GNU_GCC_REGEXP
 | 
			
		||||
    rescue FormulaUnavailableError
 | 
			
		||||
      # Don't fail and don't add these formulae to the path if they don't exist.
 | 
			
		||||
      nil
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ class DependencyCollector
 | 
			
		||||
      dep = Dependency.new("openjdk", tags)
 | 
			
		||||
      return dep if dep.installed?
 | 
			
		||||
      return req if req.satisfied?
 | 
			
		||||
 | 
			
		||||
      dep
 | 
			
		||||
    rescue FormulaUnavailableError
 | 
			
		||||
      req
 | 
			
		||||
 | 
			
		||||
@ -106,6 +106,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      def check_xcode_minimum_version
 | 
			
		||||
        return unless MacOS::Xcode.below_minimum_version?
 | 
			
		||||
 | 
			
		||||
        xcode = MacOS::Xcode.version.to_s
 | 
			
		||||
        xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix?
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -36,21 +36,15 @@ class SystemConfig
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def clt
 | 
			
		||||
      @clt ||= if MacOS::CLT.installed?
 | 
			
		||||
        MacOS::CLT.version
 | 
			
		||||
      end
 | 
			
		||||
      @clt ||= MacOS::CLT.version if MacOS::CLT.installed?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def clt_headers
 | 
			
		||||
      @clt_headers ||= if MacOS::CLT.headers_installed?
 | 
			
		||||
        MacOS::CLT.headers_version
 | 
			
		||||
      end
 | 
			
		||||
      @clt_headers ||= MacOS::CLT.headers_version if MacOS::CLT.headers_installed?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def xquartz
 | 
			
		||||
      @xquartz ||= if MacOS::XQuartz.installed?
 | 
			
		||||
        "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}"
 | 
			
		||||
      end
 | 
			
		||||
      @xquartz ||= "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" if MacOS::XQuartz.installed?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def dump_verbose_config(f = $stdout)
 | 
			
		||||
 | 
			
		||||
@ -345,9 +345,7 @@ class Pathname
 | 
			
		||||
  # Writes an exec script that invokes a Java jar
 | 
			
		||||
  def write_jar_script(target_jar, script_name, java_opts = "", java_version: nil)
 | 
			
		||||
    mkpath
 | 
			
		||||
    java_home = if java_version
 | 
			
		||||
      "JAVA_HOME=\"#{Language::Java.java_home_shell(java_version)}\" "
 | 
			
		||||
    end
 | 
			
		||||
    java_home = ("JAVA_HOME=\"#{Language::Java.java_home_shell(java_version)}\" " if java_version)
 | 
			
		||||
    join(script_name).write <<~SH
 | 
			
		||||
      #!/bin/bash
 | 
			
		||||
      #{java_home}exec java #{java_opts} -jar #{target_jar} "$@"
 | 
			
		||||
 | 
			
		||||
@ -28,18 +28,14 @@ module StringInreplaceExtension
 | 
			
		||||
 | 
			
		||||
  def sub!(before, after)
 | 
			
		||||
    result = super
 | 
			
		||||
    unless result
 | 
			
		||||
      errors << "expected replacement of #{before.inspect} with #{after.inspect}"
 | 
			
		||||
    end
 | 
			
		||||
    errors << "expected replacement of #{before.inspect} with #{after.inspect}" unless result
 | 
			
		||||
    result
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Warn if nothing was replaced
 | 
			
		||||
  def gsub!(before, after, audit_result = true)
 | 
			
		||||
    result = super(before, after)
 | 
			
		||||
    if audit_result && result.nil?
 | 
			
		||||
      errors << "expected replacement of #{before.inspect} with #{after.inspect}"
 | 
			
		||||
    end
 | 
			
		||||
    errors << "expected replacement of #{before.inspect} with #{after.inspect}" if audit_result && result.nil?
 | 
			
		||||
    result
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -55,9 +51,7 @@ module StringInreplaceExtension
 | 
			
		||||
  def remove_make_var!(flags)
 | 
			
		||||
    Array(flags).each do |flag|
 | 
			
		||||
      # Also remove trailing \n, if present.
 | 
			
		||||
      unless gsub!(/^#{Regexp.escape(flag)}[ \t]*=.*$\n?/, "", false)
 | 
			
		||||
        errors << "expected to remove #{flag.inspect}"
 | 
			
		||||
      end
 | 
			
		||||
      errors << "expected to remove #{flag.inspect}" unless gsub!(/^#{Regexp.escape(flag)}[ \t]*=.*$\n?/, "", false)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -176,9 +176,7 @@ class Formula
 | 
			
		||||
    @name = name
 | 
			
		||||
    @path = path
 | 
			
		||||
    @alias_path = alias_path
 | 
			
		||||
    @alias_name = if alias_path
 | 
			
		||||
      File.basename(alias_path)
 | 
			
		||||
    end
 | 
			
		||||
    @alias_name = (File.basename(alias_path) if alias_path)
 | 
			
		||||
    @revision = self.class.revision || 0
 | 
			
		||||
    @version_scheme = self.class.version_scheme || 0
 | 
			
		||||
 | 
			
		||||
@ -248,14 +246,10 @@ class Formula
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def validate_attributes!
 | 
			
		||||
    if name.nil? || name.empty? || name =~ /\s/
 | 
			
		||||
      raise FormulaValidationError.new(full_name, :name, name)
 | 
			
		||||
    end
 | 
			
		||||
    raise FormulaValidationError.new(full_name, :name, name) if name.nil? || name.empty? || name =~ /\s/
 | 
			
		||||
 | 
			
		||||
    url = active_spec.url
 | 
			
		||||
    if url.nil? || url.empty? || url =~ /\s/
 | 
			
		||||
      raise FormulaValidationError.new(full_name, :url, url)
 | 
			
		||||
    end
 | 
			
		||||
    raise FormulaValidationError.new(full_name, :url, url) if url.nil? || url.empty? || url =~ /\s/
 | 
			
		||||
 | 
			
		||||
    val = version.respond_to?(:to_str) ? version.to_str : version
 | 
			
		||||
    return unless val.nil? || val.empty? || val =~ /\s/
 | 
			
		||||
@ -1338,9 +1332,7 @@ class Formula
 | 
			
		||||
 | 
			
		||||
    # Avoid false positives for clock_gettime support on 10.11.
 | 
			
		||||
    # CMake cache entries for other weak symbols may be added here as needed.
 | 
			
		||||
    if MacOS.version == "10.11" && MacOS::Xcode.version >= "8.0"
 | 
			
		||||
      args << "-DHAVE_CLOCK_GETTIME:INTERNAL=0"
 | 
			
		||||
    end
 | 
			
		||||
    args << "-DHAVE_CLOCK_GETTIME:INTERNAL=0" if MacOS.version == "10.11" && MacOS::Xcode.version >= "8.0"
 | 
			
		||||
 | 
			
		||||
    args
 | 
			
		||||
  end
 | 
			
		||||
@ -1842,9 +1834,7 @@ class Formula
 | 
			
		||||
      pretty_args.delete "--disable-debug"
 | 
			
		||||
    end
 | 
			
		||||
    pretty_args.each_index do |i|
 | 
			
		||||
      if pretty_args[i].to_s.start_with? "import setuptools"
 | 
			
		||||
        pretty_args[i] = "import setuptools..."
 | 
			
		||||
      end
 | 
			
		||||
      pretty_args[i] = "import setuptools..." if pretty_args[i].to_s.start_with? "import setuptools"
 | 
			
		||||
    end
 | 
			
		||||
    ohai "#{cmd} #{pretty_args * " "}".strip
 | 
			
		||||
 | 
			
		||||
@ -1957,9 +1947,7 @@ class Formula
 | 
			
		||||
      # If the cellar only has one version installed, don't complain
 | 
			
		||||
      # that we can't tell which one to keep. Don't complain at all if the
 | 
			
		||||
      # only installed version is a pinned formula.
 | 
			
		||||
      unless quiet
 | 
			
		||||
        opoo "Skipping #{full_name}: most recent version #{pkg_version} not installed"
 | 
			
		||||
      end
 | 
			
		||||
      opoo "Skipping #{full_name}: most recent version #{pkg_version} not installed" unless quiet
 | 
			
		||||
    end
 | 
			
		||||
    eligible_for_cleanup
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -244,9 +244,7 @@ class FormulaInstaller
 | 
			
		||||
 | 
			
		||||
    check_conflicts
 | 
			
		||||
 | 
			
		||||
    if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed?
 | 
			
		||||
      raise BuildToolsError, [formula]
 | 
			
		||||
    end
 | 
			
		||||
    raise BuildToolsError, [formula] if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed?
 | 
			
		||||
 | 
			
		||||
    unless ignore_deps?
 | 
			
		||||
      deps = compute_dependencies
 | 
			
		||||
@ -267,17 +265,13 @@ class FormulaInstaller
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    options = display_options(formula)
 | 
			
		||||
    if show_header?
 | 
			
		||||
      oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip
 | 
			
		||||
    end
 | 
			
		||||
    oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header?
 | 
			
		||||
 | 
			
		||||
    unless formula.tap&.private?
 | 
			
		||||
      action = "#{formula.full_name} #{options}".strip
 | 
			
		||||
      Utils::Analytics.report_event("install", action)
 | 
			
		||||
 | 
			
		||||
      if installed_on_request
 | 
			
		||||
        Utils::Analytics.report_event("install_on_request", action)
 | 
			
		||||
      end
 | 
			
		||||
      Utils::Analytics.report_event("install_on_request", action) if installed_on_request
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    self.class.attempted << formula
 | 
			
		||||
@ -624,9 +618,7 @@ class FormulaInstaller
 | 
			
		||||
    keg = Keg.new(formula.prefix)
 | 
			
		||||
    link(keg)
 | 
			
		||||
 | 
			
		||||
    unless @poured_bottle && formula.bottle_specification.skip_relocation?
 | 
			
		||||
      fix_dynamic_linkage(keg)
 | 
			
		||||
    end
 | 
			
		||||
    fix_dynamic_linkage(keg) unless @poured_bottle && formula.bottle_specification.skip_relocation?
 | 
			
		||||
 | 
			
		||||
    if build_bottle?
 | 
			
		||||
      ohai "Not running post_install as we're building a bottle"
 | 
			
		||||
@ -757,9 +749,7 @@ class FormulaInstaller
 | 
			
		||||
 | 
			
		||||
    formula.update_head_version
 | 
			
		||||
 | 
			
		||||
    if !formula.prefix.directory? || Keg.new(formula.prefix).empty_installation?
 | 
			
		||||
      raise "Empty installation"
 | 
			
		||||
    end
 | 
			
		||||
    raise "Empty installation" if !formula.prefix.directory? || Keg.new(formula.prefix).empty_installation?
 | 
			
		||||
  rescue Exception => e # rubocop:disable Lint/RescueException
 | 
			
		||||
    if e.is_a? BuildError
 | 
			
		||||
      e.formula = formula
 | 
			
		||||
 | 
			
		||||
@ -16,9 +16,7 @@ module Formulary
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.load_formula(name, path, contents, namespace)
 | 
			
		||||
    if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
 | 
			
		||||
      raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!"
 | 
			
		||||
    end
 | 
			
		||||
    raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!" if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
 | 
			
		||||
 | 
			
		||||
    mod = Module.new
 | 
			
		||||
    const_set(namespace, mod)
 | 
			
		||||
@ -244,9 +242,7 @@ module Formulary
 | 
			
		||||
          new_name = new_tap.core_tap? ? name : new_tapped_name
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        if warn && old_name && new_name
 | 
			
		||||
          opoo "Use #{new_name} instead of deprecated #{old_name}"
 | 
			
		||||
        end
 | 
			
		||||
        opoo "Use #{new_name} instead of deprecated #{old_name}" if warn && old_name && new_name
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      [name, path]
 | 
			
		||||
@ -397,22 +393,16 @@ module Formulary
 | 
			
		||||
      return TapLoader.new(ref, from: from)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if File.extname(ref) == ".rb" && Pathname.new(ref).expand_path.exist?
 | 
			
		||||
      return FromPathLoader.new(ref)
 | 
			
		||||
    end
 | 
			
		||||
    return FromPathLoader.new(ref) if File.extname(ref) == ".rb" && Pathname.new(ref).expand_path.exist?
 | 
			
		||||
 | 
			
		||||
    formula_with_that_name = core_path(ref)
 | 
			
		||||
    if formula_with_that_name.file?
 | 
			
		||||
      return FormulaLoader.new(ref, formula_with_that_name)
 | 
			
		||||
    end
 | 
			
		||||
    return FormulaLoader.new(ref, formula_with_that_name) if formula_with_that_name.file?
 | 
			
		||||
 | 
			
		||||
    possible_alias = CoreTap.instance.alias_dir/ref
 | 
			
		||||
    return AliasLoader.new(possible_alias) if possible_alias.file?
 | 
			
		||||
 | 
			
		||||
    possible_tap_formulae = tap_paths(ref)
 | 
			
		||||
    if possible_tap_formulae.size > 1
 | 
			
		||||
      raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae)
 | 
			
		||||
    end
 | 
			
		||||
    raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae) if possible_tap_formulae.size > 1
 | 
			
		||||
 | 
			
		||||
    if possible_tap_formulae.size == 1
 | 
			
		||||
      path = possible_tap_formulae.first.resolved_path
 | 
			
		||||
@ -422,9 +412,7 @@ module Formulary
 | 
			
		||||
 | 
			
		||||
    if newref = CoreTap.instance.formula_renames[ref]
 | 
			
		||||
      formula_with_that_oldname = core_path(newref)
 | 
			
		||||
      if formula_with_that_oldname.file?
 | 
			
		||||
        return FormulaLoader.new(newref, formula_with_that_oldname)
 | 
			
		||||
      end
 | 
			
		||||
      return FormulaLoader.new(newref, formula_with_that_oldname) if formula_with_that_oldname.file?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    possible_tap_newname_formulae = []
 | 
			
		||||
@ -438,19 +426,13 @@ module Formulary
 | 
			
		||||
      raise TapFormulaWithOldnameAmbiguityError.new(ref, possible_tap_newname_formulae)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless possible_tap_newname_formulae.empty?
 | 
			
		||||
      return TapLoader.new(possible_tap_newname_formulae.first, from: from)
 | 
			
		||||
    end
 | 
			
		||||
    return TapLoader.new(possible_tap_newname_formulae.first, from: from) unless possible_tap_newname_formulae.empty?
 | 
			
		||||
 | 
			
		||||
    possible_keg_formula = Pathname.new("#{HOMEBREW_PREFIX}/opt/#{ref}/.brew/#{ref}.rb")
 | 
			
		||||
    if possible_keg_formula.file?
 | 
			
		||||
      return FormulaLoader.new(ref, possible_keg_formula)
 | 
			
		||||
    end
 | 
			
		||||
    return FormulaLoader.new(ref, possible_keg_formula) if possible_keg_formula.file?
 | 
			
		||||
 | 
			
		||||
    possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{ref}.rb")
 | 
			
		||||
    if possible_cached_formula.file?
 | 
			
		||||
      return FormulaLoader.new(ref, possible_cached_formula)
 | 
			
		||||
    end
 | 
			
		||||
    return FormulaLoader.new(ref, possible_cached_formula) if possible_cached_formula.file?
 | 
			
		||||
 | 
			
		||||
    NullLoader.new(ref)
 | 
			
		||||
  end
 | 
			
		||||
@ -473,9 +455,7 @@ module Formulary
 | 
			
		||||
 | 
			
		||||
  def self.find_with_priority(ref, spec = :stable)
 | 
			
		||||
    possible_pinned_tap_formulae = tap_paths(ref, Dir["#{HOMEBREW_LIBRARY}/PinnedTaps/*/*/"]).map(&:realpath)
 | 
			
		||||
    if possible_pinned_tap_formulae.size > 1
 | 
			
		||||
      raise TapFormulaAmbiguityError.new(ref, possible_pinned_tap_formulae)
 | 
			
		||||
    end
 | 
			
		||||
    raise TapFormulaAmbiguityError.new(ref, possible_pinned_tap_formulae) if possible_pinned_tap_formulae.size > 1
 | 
			
		||||
 | 
			
		||||
    if possible_pinned_tap_formulae.size == 1
 | 
			
		||||
      selected_formula = factory(possible_pinned_tap_formulae.first, spec)
 | 
			
		||||
 | 
			
		||||
@ -148,6 +148,4 @@ require "official_taps"
 | 
			
		||||
require "tap"
 | 
			
		||||
require "tap_constants"
 | 
			
		||||
 | 
			
		||||
if !ARGV.include?("--no-compat") && !ENV["HOMEBREW_NO_COMPAT"]
 | 
			
		||||
  require "compat"
 | 
			
		||||
end
 | 
			
		||||
require "compat" if !ARGV.include?("--no-compat") && !ENV["HOMEBREW_NO_COMPAT"]
 | 
			
		||||
 | 
			
		||||
@ -83,6 +83,7 @@ module Homebrew
 | 
			
		||||
                       .generate_help_text
 | 
			
		||||
      rescue NoMethodError => e
 | 
			
		||||
        raise if e.name != cmd_args_method_name
 | 
			
		||||
 | 
			
		||||
        nil
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -263,9 +263,7 @@ class Keg
 | 
			
		||||
 | 
			
		||||
    if tap
 | 
			
		||||
      bad_tap_opt = opt/tap.user
 | 
			
		||||
      if !bad_tap_opt.symlink? && bad_tap_opt.directory?
 | 
			
		||||
        FileUtils.rm_rf bad_tap_opt
 | 
			
		||||
      end
 | 
			
		||||
      FileUtils.rm_rf bad_tap_opt if !bad_tap_opt.symlink? && bad_tap_opt.directory?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    aliases.each do |a|
 | 
			
		||||
@ -569,9 +567,7 @@ class Keg
 | 
			
		||||
    begin
 | 
			
		||||
      keg = Keg.for(src)
 | 
			
		||||
    rescue NotAKegError
 | 
			
		||||
      if ARGV.verbose?
 | 
			
		||||
        puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar"
 | 
			
		||||
      end
 | 
			
		||||
      puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if ARGV.verbose?
 | 
			
		||||
      return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -636,9 +632,7 @@ class Keg
 | 
			
		||||
        # Don't link pyc or pyo files because Python overwrites these
 | 
			
		||||
        # cached object files and next time brew wants to link, the
 | 
			
		||||
        # file is in the way.
 | 
			
		||||
        if %w[.pyc .pyo].include?(src.extname) && src.to_s.include?("/site-packages/")
 | 
			
		||||
          Find.prune
 | 
			
		||||
        end
 | 
			
		||||
        Find.prune if %w[.pyc .pyo].include?(src.extname) && src.to_s.include?("/site-packages/")
 | 
			
		||||
 | 
			
		||||
        case yield src.relative_path_from(root)
 | 
			
		||||
        when :skip_file, nil
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,7 @@ module Language
 | 
			
		||||
    def self.java_home(version = nil)
 | 
			
		||||
      req = JavaRequirement.new [*version]
 | 
			
		||||
      raise UnsatisfiedRequirements, req.message unless req.satisfied?
 | 
			
		||||
 | 
			
		||||
      req.java_home
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -11,9 +11,7 @@ module Language
 | 
			
		||||
      # directory, consequently breaking that assumption. We require a tarball
 | 
			
		||||
      # because npm install creates a "real" installation when fed a tarball.
 | 
			
		||||
      output = Utils.popen_read("npm pack --ignore-scripts")
 | 
			
		||||
      if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty?
 | 
			
		||||
        raise "npm failed to pack #{Dir.pwd}"
 | 
			
		||||
      end
 | 
			
		||||
      raise "npm failed to pack #{Dir.pwd}" if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty?
 | 
			
		||||
 | 
			
		||||
      output.lines.last.chomp
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -2,8 +2,6 @@ require "pathname"
 | 
			
		||||
 | 
			
		||||
HOMEBREW_LIBRARY_PATH = Pathname(__dir__).realpath
 | 
			
		||||
 | 
			
		||||
unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
 | 
			
		||||
  $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.to_s)
 | 
			
		||||
end
 | 
			
		||||
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.to_s) unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
 | 
			
		||||
 | 
			
		||||
require "vendor/bundle-standalone/bundler/setup"
 | 
			
		||||
 | 
			
		||||
@ -11,9 +11,7 @@ class Locale
 | 
			
		||||
  def self.parse(string)
 | 
			
		||||
    string = string.to_s
 | 
			
		||||
 | 
			
		||||
    if string !~ LOCALE_REGEX
 | 
			
		||||
      raise ParserError, "'#{string}' cannot be parsed to a #{self}"
 | 
			
		||||
    end
 | 
			
		||||
    raise ParserError, "'#{string}' cannot be parsed to a #{self}" if string !~ LOCALE_REGEX
 | 
			
		||||
 | 
			
		||||
    scan = proc do |regex|
 | 
			
		||||
      string.scan(/(?:\-|^)(#{regex})(?:\-|$)/).flatten.first
 | 
			
		||||
@ -29,9 +27,7 @@ class Locale
 | 
			
		||||
  attr_reader :language, :region, :script
 | 
			
		||||
 | 
			
		||||
  def initialize(language, region, script)
 | 
			
		||||
    if language.nil? && region.nil? && script.nil?
 | 
			
		||||
      raise ArgumentError, "#{self.class} cannot be empty"
 | 
			
		||||
    end
 | 
			
		||||
    raise ArgumentError, "#{self.class} cannot be empty" if language.nil? && region.nil? && script.nil?
 | 
			
		||||
 | 
			
		||||
    {
 | 
			
		||||
      language: language,
 | 
			
		||||
 | 
			
		||||
@ -118,9 +118,7 @@ class Migrator
 | 
			
		||||
    @old_tabs = old_cellar.subdirs.map { |d| Tab.for_keg(Keg.new(d)) }
 | 
			
		||||
    @old_tap = old_tabs.first.tap
 | 
			
		||||
 | 
			
		||||
    if !force && !from_same_tap_user?
 | 
			
		||||
      raise MigratorDifferentTapsError.new(formula, old_tap)
 | 
			
		||||
    end
 | 
			
		||||
    raise MigratorDifferentTapsError.new(formula, old_tap) if !force && !from_same_tap_user?
 | 
			
		||||
 | 
			
		||||
    @new_cellar = HOMEBREW_CELLAR/formula.name
 | 
			
		||||
    @new_cellar_existed = @new_cellar.exist?
 | 
			
		||||
@ -233,9 +231,7 @@ class Migrator
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if conflicted
 | 
			
		||||
        odie "Remove #{new_cellar} manually and run brew migrate #{oldname}."
 | 
			
		||||
      end
 | 
			
		||||
      odie "Remove #{new_cellar} manually and run brew migrate #{oldname}." if conflicted
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    oh1 "Moving #{Formatter.identifier(oldname)} versions to #{new_cellar}"
 | 
			
		||||
 | 
			
		||||
@ -310,6 +310,7 @@ module OS
 | 
			
		||||
        version = nil
 | 
			
		||||
        [EXECUTABLE_PKG_ID, MAVERICKS_NEW_PKG_ID].each do |id|
 | 
			
		||||
          next unless File.exist?("#{PKG_PATH}/usr/bin/clang")
 | 
			
		||||
 | 
			
		||||
          version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1]
 | 
			
		||||
          break if version
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
@ -87,9 +87,7 @@ module OS
 | 
			
		||||
      # remain public. New code should use `MacOS::X11.bin`, `MacOS::X11.lib` and
 | 
			
		||||
      # `MacOS::X11.include` instead, as that accounts for Xcode-only systems.
 | 
			
		||||
      def prefix
 | 
			
		||||
        @prefix ||= if Pathname.new("/opt/X11/lib/libpng.dylib").exist?
 | 
			
		||||
          Pathname.new("/opt/X11")
 | 
			
		||||
        end
 | 
			
		||||
        @prefix ||= Pathname.new("/opt/X11") if Pathname.new("/opt/X11/lib/libpng.dylib").exist?
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def installed?
 | 
			
		||||
 | 
			
		||||
@ -3,12 +3,8 @@ class CodesignRequirement < Requirement
 | 
			
		||||
 | 
			
		||||
  def initialize(tags)
 | 
			
		||||
    options = tags.shift
 | 
			
		||||
    unless options.is_a?(Hash)
 | 
			
		||||
      raise ArgumentError("CodesignRequirement requires an options Hash!")
 | 
			
		||||
    end
 | 
			
		||||
    unless options.key?(:identity)
 | 
			
		||||
      raise ArgumentError("CodesignRequirement requires an identity key!")
 | 
			
		||||
    end
 | 
			
		||||
    raise ArgumentError("CodesignRequirement requires an options Hash!") unless options.is_a?(Hash)
 | 
			
		||||
    raise ArgumentError("CodesignRequirement requires an identity key!") unless options.key?(:identity)
 | 
			
		||||
 | 
			
		||||
    @identity = options.fetch(:identity)
 | 
			
		||||
    @with = options.fetch(:with, "code signing")
 | 
			
		||||
 | 
			
		||||
@ -66,9 +66,7 @@ class Resource
 | 
			
		||||
  # directory. Subclasses that override stage should implement the tmp
 | 
			
		||||
  # dir using {Mktemp} so that works with all subtypes.
 | 
			
		||||
  def stage(target = nil, &block)
 | 
			
		||||
    unless target || block
 | 
			
		||||
      raise ArgumentError, "target directory or block is required"
 | 
			
		||||
    end
 | 
			
		||||
    raise ArgumentError, "target directory or block is required" unless target || block
 | 
			
		||||
 | 
			
		||||
    verify_download_integrity(fetch)
 | 
			
		||||
    prepare_patches
 | 
			
		||||
 | 
			
		||||
@ -7,13 +7,9 @@ module RuboCop
 | 
			
		||||
        def audit_formula(_node, _class_node, _parent_class_node, body_node)
 | 
			
		||||
          return if body_node.nil?
 | 
			
		||||
 | 
			
		||||
          if method_called_ever?(body_node, :md5)
 | 
			
		||||
            problem "MD5 checksums are deprecated, please use SHA256"
 | 
			
		||||
          end
 | 
			
		||||
          problem "MD5 checksums are deprecated, please use SHA256" if method_called_ever?(body_node, :md5)
 | 
			
		||||
 | 
			
		||||
          if method_called_ever?(body_node, :sha1)
 | 
			
		||||
            problem "SHA1 checksums are deprecated, please use SHA256"
 | 
			
		||||
          end
 | 
			
		||||
          problem "SHA1 checksums are deprecated, please use SHA256" if method_called_ever?(body_node, :sha1)
 | 
			
		||||
 | 
			
		||||
          sha256_calls = find_every_method_call_by_name(body_node, :sha256)
 | 
			
		||||
          sha256_calls.each do |sha256_call|
 | 
			
		||||
 | 
			
		||||
@ -367,9 +367,7 @@ module RuboCop
 | 
			
		||||
      def check_precedence(first_nodes, next_nodes)
 | 
			
		||||
        next_nodes.each do |each_next_node|
 | 
			
		||||
          first_nodes.each do |each_first_node|
 | 
			
		||||
            if component_precedes?(each_first_node, each_next_node)
 | 
			
		||||
              return [each_first_node, each_next_node]
 | 
			
		||||
            end
 | 
			
		||||
            return [each_first_node, each_next_node] if component_precedes?(each_first_node, each_next_node)
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
        nil
 | 
			
		||||
 | 
			
		||||
@ -65,14 +65,10 @@ module RuboCop
 | 
			
		||||
          desc = parameters(desc_call).first
 | 
			
		||||
 | 
			
		||||
          # Check for leading whitespace.
 | 
			
		||||
          if regex_match_group(desc, /^\s+/)
 | 
			
		||||
            problem "Description shouldn't have a leading space"
 | 
			
		||||
          end
 | 
			
		||||
          problem "Description shouldn't have a leading space" if regex_match_group(desc, /^\s+/)
 | 
			
		||||
 | 
			
		||||
          # Check for trailing whitespace.
 | 
			
		||||
          if regex_match_group(desc, /\s+$/)
 | 
			
		||||
            problem "Description shouldn't have a trailing space"
 | 
			
		||||
          end
 | 
			
		||||
          problem "Description shouldn't have a trailing space" if regex_match_group(desc, /\s+$/)
 | 
			
		||||
 | 
			
		||||
          # Check if command-line is wrongly used in formula's desc
 | 
			
		||||
          if match = regex_match_group(desc, /(command ?line)/i)
 | 
			
		||||
 | 
			
		||||
@ -89,9 +89,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
      class OptionDeclarations < FormulaCop
 | 
			
		||||
        def audit_formula(_node, _class_node, _parent_class_node, body_node)
 | 
			
		||||
          if find_method_def(body_node, :options)
 | 
			
		||||
            problem "Use new-style option definitions"
 | 
			
		||||
          end
 | 
			
		||||
          problem "Use new-style option definitions" if find_method_def(body_node, :options)
 | 
			
		||||
 | 
			
		||||
          find_instance_method_call(body_node, :build, :without?) do |method|
 | 
			
		||||
            next unless unless_modifier?(method.parent)
 | 
			
		||||
@ -327,9 +325,7 @@ module RuboCop
 | 
			
		||||
            problem "Use Language::Node for npm install args" unless languageNodeModule?(method_node)
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          if find_method_def(body_node, :test)
 | 
			
		||||
            problem "Use new-style test definitions (test do)"
 | 
			
		||||
          end
 | 
			
		||||
          problem "Use new-style test definitions (test do)" if find_method_def(body_node, :test)
 | 
			
		||||
 | 
			
		||||
          find_method_with_args(body_node, :skip_clean, :all) do
 | 
			
		||||
            problem "`skip_clean :all` is deprecated; brew no longer strips symbols. " \
 | 
			
		||||
 | 
			
		||||
@ -97,9 +97,7 @@ module RuboCop
 | 
			
		||||
              problem "Don't use #{Regexp.last_match(1)}use_mirror in SourceForge urls (url is #{url})."
 | 
			
		||||
            end
 | 
			
		||||
 | 
			
		||||
            if url.end_with?("/download")
 | 
			
		||||
              problem "Don't use /download in SourceForge urls (url is #{url})."
 | 
			
		||||
            end
 | 
			
		||||
            problem "Don't use /download in SourceForge urls (url is #{url})." if url.end_with?("/download")
 | 
			
		||||
 | 
			
		||||
            if url =~ %r{^https?://sourceforge\.}
 | 
			
		||||
              problem "Use https://downloads.sourceforge.net to get geolocation (url is #{url})."
 | 
			
		||||
 | 
			
		||||
@ -55,9 +55,7 @@ class SoftwareSpec
 | 
			
		||||
    resources.each_value do |r|
 | 
			
		||||
      r.owner = self
 | 
			
		||||
      r.version ||= begin
 | 
			
		||||
        if version.nil?
 | 
			
		||||
          raise "#{full_name}: version missing for \"#{r.name}\" resource!"
 | 
			
		||||
        end
 | 
			
		||||
        raise "#{full_name}: version missing for \"#{r.name}\" resource!" if version.nil?
 | 
			
		||||
 | 
			
		||||
        if version.head?
 | 
			
		||||
          Version.create("HEAD")
 | 
			
		||||
 | 
			
		||||
@ -30,9 +30,7 @@ module Homebrew
 | 
			
		||||
        args << "--parallel"
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if ARGV.verbose?
 | 
			
		||||
        args += ["--extra-details", "--display-cop-names"]
 | 
			
		||||
      end
 | 
			
		||||
      args += ["--extra-details", "--display-cop-names"] if ARGV.verbose?
 | 
			
		||||
 | 
			
		||||
      if options[:except_cops]
 | 
			
		||||
        options[:except_cops].map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") }
 | 
			
		||||
@ -49,9 +47,7 @@ module Homebrew
 | 
			
		||||
            RuboCop::Cop::Cop.registry.departments.include?(cop.to_sym)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        if cops_to_include.empty?
 | 
			
		||||
          odie "RuboCops #{options[:only_cops].join(",")} were not found"
 | 
			
		||||
        end
 | 
			
		||||
        odie "RuboCops #{options[:only_cops].join(",")} were not found" if cops_to_include.empty?
 | 
			
		||||
 | 
			
		||||
        args << "--only" << cops_to_include.join(",")
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -197,6 +197,7 @@ class SystemCommand
 | 
			
		||||
 | 
			
		||||
    def success?
 | 
			
		||||
      return false if @exit_status.nil?
 | 
			
		||||
 | 
			
		||||
      @exit_status.zero?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -157,15 +157,9 @@ class SystemConfig
 | 
			
		||||
      if defaults_hash[:HOMEBREW_REPOSITORY] != HOMEBREW_REPOSITORY.to_s
 | 
			
		||||
        f.puts "HOMEBREW_REPOSITORY: #{HOMEBREW_REPOSITORY}"
 | 
			
		||||
      end
 | 
			
		||||
      if defaults_hash[:HOMEBREW_CELLAR] != HOMEBREW_CELLAR.to_s
 | 
			
		||||
        f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}"
 | 
			
		||||
      end
 | 
			
		||||
      if defaults_hash[:HOMEBREW_CACHE] != HOMEBREW_CACHE.to_s
 | 
			
		||||
        f.puts "HOMEBREW_CACHE: #{HOMEBREW_CACHE}"
 | 
			
		||||
      end
 | 
			
		||||
      if defaults_hash[:HOMEBREW_TEMP] != HOMEBREW_TEMP.to_s
 | 
			
		||||
        f.puts "HOMEBREW_TEMP: #{HOMEBREW_TEMP}"
 | 
			
		||||
      end
 | 
			
		||||
      f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" if defaults_hash[:HOMEBREW_CELLAR] != HOMEBREW_CELLAR.to_s
 | 
			
		||||
      f.puts "HOMEBREW_CACHE: #{HOMEBREW_CACHE}" if defaults_hash[:HOMEBREW_CACHE] != HOMEBREW_CACHE.to_s
 | 
			
		||||
      f.puts "HOMEBREW_TEMP: #{HOMEBREW_TEMP}" if defaults_hash[:HOMEBREW_TEMP] != HOMEBREW_TEMP.to_s
 | 
			
		||||
      if defaults_hash[:HOMEBREW_RUBY_WARNINGS] != ENV["HOMEBREW_RUBY_WARNINGS"].to_s
 | 
			
		||||
        f.puts "HOMEBREW_RUBY_WARNINGS: #{ENV["HOMEBREW_RUBY_WARNINGS"]}"
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -133,13 +133,9 @@ class Tab < OpenStruct
 | 
			
		||||
  def self.for_formula(f)
 | 
			
		||||
    paths = []
 | 
			
		||||
 | 
			
		||||
    if f.opt_prefix.symlink? && f.opt_prefix.directory?
 | 
			
		||||
      paths << f.opt_prefix.resolved_path
 | 
			
		||||
    end
 | 
			
		||||
    paths << f.opt_prefix.resolved_path if f.opt_prefix.symlink? && f.opt_prefix.directory?
 | 
			
		||||
 | 
			
		||||
    if f.linked_keg.symlink? && f.linked_keg.directory?
 | 
			
		||||
      paths << f.linked_keg.resolved_path
 | 
			
		||||
    end
 | 
			
		||||
    paths << f.linked_keg.resolved_path if f.linked_keg.symlink? && f.linked_keg.directory?
 | 
			
		||||
 | 
			
		||||
    if (dirs = f.installed_prefixes).length == 1
 | 
			
		||||
      paths << dirs.first
 | 
			
		||||
 | 
			
		||||
@ -22,17 +22,13 @@ class Tap
 | 
			
		||||
      repo = args.second
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if [user, repo].any? { |part| part.nil? || part.include?("/") }
 | 
			
		||||
      raise "Invalid tap name '#{args.join("/")}'"
 | 
			
		||||
    end
 | 
			
		||||
    raise "Invalid tap name '#{args.join("/")}'" if [user, repo].any? { |part| part.nil? || part.include?("/") }
 | 
			
		||||
 | 
			
		||||
    # We special case homebrew and linuxbrew so that users don't have to shift in a terminal.
 | 
			
		||||
    user = user.capitalize if ["homebrew", "linuxbrew"].include? user
 | 
			
		||||
    repo = repo.delete_prefix "homebrew-"
 | 
			
		||||
 | 
			
		||||
    if ["Homebrew", "Linuxbrew"].include?(user) && ["core", "homebrew"].include?(repo)
 | 
			
		||||
      return CoreTap.instance
 | 
			
		||||
    end
 | 
			
		||||
    return CoreTap.instance if ["Homebrew", "Linuxbrew"].include?(user) && ["core", "homebrew"].include?(repo)
 | 
			
		||||
 | 
			
		||||
    cache_key = "#{user}/#{repo}".downcase
 | 
			
		||||
    cache.fetch(cache_key) { |key| cache[key] = Tap.new(user, repo) }
 | 
			
		||||
@ -280,9 +276,7 @@ class Tap
 | 
			
		||||
    begin
 | 
			
		||||
      safe_system "git", *args
 | 
			
		||||
      unless Readall.valid_tap?(self, aliases: true)
 | 
			
		||||
        unless ARGV.homebrew_developer?
 | 
			
		||||
          raise "Cannot tap #{name}: invalid syntax in tap!"
 | 
			
		||||
        end
 | 
			
		||||
        raise "Cannot tap #{name}: invalid syntax in tap!" unless ARGV.homebrew_developer?
 | 
			
		||||
      end
 | 
			
		||||
    rescue Interrupt, RuntimeError
 | 
			
		||||
      ignore_interrupts do
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,7 @@ GEM
 | 
			
		||||
    parser (2.6.0.0)
 | 
			
		||||
      ast (~> 2.4.0)
 | 
			
		||||
    powerpack (0.1.2)
 | 
			
		||||
    psych (3.1.0)
 | 
			
		||||
    rainbow (3.0.0)
 | 
			
		||||
    rdiscount (2.2.0.1)
 | 
			
		||||
    ronn (0.7.3)
 | 
			
		||||
@ -46,11 +47,12 @@ GEM
 | 
			
		||||
    rspec-support (3.8.0)
 | 
			
		||||
    rspec-wait (0.0.9)
 | 
			
		||||
      rspec (>= 3, < 4)
 | 
			
		||||
    rubocop (0.64.0)
 | 
			
		||||
    rubocop (0.65.0)
 | 
			
		||||
      jaro_winkler (~> 1.5.1)
 | 
			
		||||
      parallel (~> 1.10)
 | 
			
		||||
      parser (>= 2.5, != 2.5.1.1)
 | 
			
		||||
      powerpack (~> 0.1)
 | 
			
		||||
      psych (>= 3.1.0)
 | 
			
		||||
      rainbow (>= 2.2.2, < 4.0)
 | 
			
		||||
      ruby-progressbar (~> 1.7)
 | 
			
		||||
      unicode-display_width (~> 1.4.0)
 | 
			
		||||
 | 
			
		||||
@ -5,9 +5,7 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
 | 
			
		||||
  if ENV["HOMEBREW_COVERALLS_REPO_TOKEN"]
 | 
			
		||||
    require "coveralls"
 | 
			
		||||
 | 
			
		||||
    if !ENV["HOMEBREW_COLOR"] && (ENV["HOMEBREW_NO_COLOR"] || !$stdout.tty?)
 | 
			
		||||
      Coveralls::Output.no_color
 | 
			
		||||
    end
 | 
			
		||||
    Coveralls::Output.no_color if !ENV["HOMEBREW_COLOR"] && (ENV["HOMEBREW_NO_COLOR"] || !$stdout.tty?)
 | 
			
		||||
 | 
			
		||||
    formatters << Coveralls::SimpleCov::Formatter
 | 
			
		||||
 | 
			
		||||
@ -128,9 +126,7 @@ RSpec.configure do |config|
 | 
			
		||||
 | 
			
		||||
  config.before(:each, :needs_svn) do
 | 
			
		||||
    homebrew_bin = File.dirname HOMEBREW_BREW_FILE
 | 
			
		||||
    unless %W[/usr/bin/svn #{homebrew_bin}/svn].map { |x| File.executable?(x) }.any?
 | 
			
		||||
      skip "subversion not installed."
 | 
			
		||||
    end
 | 
			
		||||
    skip "subversion not installed." unless %W[/usr/bin/svn #{homebrew_bin}/svn].map { |x| File.executable?(x) }.any?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  config.before(:each, :needs_unzip) do
 | 
			
		||||
 | 
			
		||||
@ -176,6 +176,7 @@ RSpec.shared_context "integration test" do
 | 
			
		||||
  def setup_remote_tap(name)
 | 
			
		||||
    Tap.fetch(name).tap do |tap|
 | 
			
		||||
      next if tap.installed?
 | 
			
		||||
 | 
			
		||||
      full_name = Tap.fetch(name).full_name
 | 
			
		||||
      # Check to see if the original Homebrew process has taps we can use.
 | 
			
		||||
      system_tap_path = Pathname("#{ENV["HOMEBREW_LIBRARY"]}/Taps/#{full_name}")
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,4 @@
 | 
			
		||||
unless ENV["HOMEBREW_BREW_FILE"]
 | 
			
		||||
  raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
 | 
			
		||||
end
 | 
			
		||||
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
 | 
			
		||||
 | 
			
		||||
require "pathname"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -17,9 +17,7 @@ module UnpackStrategy
 | 
			
		||||
    def self.can_extract?(path)
 | 
			
		||||
      return true if path.magic_number.match?(/\A.{257}ustar/n)
 | 
			
		||||
 | 
			
		||||
      unless [Bzip2, Gzip, Lzip, Xz].any? { |s| s.can_extract?(path) }
 | 
			
		||||
        return false
 | 
			
		||||
      end
 | 
			
		||||
      return false unless [Bzip2, Gzip, Lzip, Xz].any? { |s| s.can_extract?(path) }
 | 
			
		||||
 | 
			
		||||
      # Check if `tar` can list the contents, then it can also extract it.
 | 
			
		||||
      IO.popen(["tar", "tf", path], err: File::NULL) do |stdout|
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ require "utils/analytics"
 | 
			
		||||
require "utils/curl"
 | 
			
		||||
require "utils/fork"
 | 
			
		||||
require "utils/formatter"
 | 
			
		||||
require "utils/gems"
 | 
			
		||||
require "utils/git"
 | 
			
		||||
require "utils/github"
 | 
			
		||||
require "utils/inreplace"
 | 
			
		||||
@ -37,9 +38,7 @@ def odebug(title, *sput)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
def oh1(title, options = {})
 | 
			
		||||
  if $stdout.tty? && !ARGV.verbose? && options.fetch(:truncate, :auto) == :auto
 | 
			
		||||
    title = Tty.truncate(title)
 | 
			
		||||
  end
 | 
			
		||||
  title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? && options.fetch(:truncate, :auto) == :auto
 | 
			
		||||
  puts Formatter.headline(title, color: :green)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -203,68 +202,6 @@ module Homebrew
 | 
			
		||||
    _system(cmd, *args, **options)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def setup_gem_environment!
 | 
			
		||||
    # Match where our bundler gems are.
 | 
			
		||||
    ENV["GEM_HOME"] = "#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/vendor/bundle/ruby/#{RbConfig::CONFIG["ruby_version"]}"
 | 
			
		||||
    ENV["GEM_PATH"] = ENV["GEM_HOME"]
 | 
			
		||||
 | 
			
		||||
    # Make rubygems notice env changes.
 | 
			
		||||
    Gem.clear_paths
 | 
			
		||||
    Gem::Specification.reset
 | 
			
		||||
 | 
			
		||||
    # Add Gem binary directory and (if missing) Ruby binary directory to PATH.
 | 
			
		||||
    path = PATH.new(ENV["PATH"])
 | 
			
		||||
    path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH
 | 
			
		||||
    path.prepend(Gem.bindir)
 | 
			
		||||
    ENV["PATH"] = path
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # TODO: version can be removed when compat/download_strategy is deleted in 2.0
 | 
			
		||||
  def install_gem!(name, version = nil)
 | 
			
		||||
    setup_gem_environment!
 | 
			
		||||
 | 
			
		||||
    return unless Gem::Specification.find_all_by_name(name, version).empty?
 | 
			
		||||
 | 
			
		||||
    ohai "Installing or updating '#{name}' gem"
 | 
			
		||||
    install_args = %W[--no-document #{name}]
 | 
			
		||||
    install_args << "--version" << version if version
 | 
			
		||||
 | 
			
		||||
    # Do `gem install [...]` without having to spawn a separate process or
 | 
			
		||||
    # having to find the right `gem` binary for the running Ruby interpreter.
 | 
			
		||||
    require "rubygems/commands/install_command"
 | 
			
		||||
    install_cmd = Gem::Commands::InstallCommand.new
 | 
			
		||||
    install_cmd.handle_options(install_args)
 | 
			
		||||
    exit_code = 1 # Should not matter as `install_cmd.execute` always throws.
 | 
			
		||||
    begin
 | 
			
		||||
      install_cmd.execute
 | 
			
		||||
    rescue Gem::SystemExitException => e
 | 
			
		||||
      exit_code = e.exit_code
 | 
			
		||||
    end
 | 
			
		||||
    odie "Failed to install/update the '#{name}' gem." if exit_code.nonzero?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install_gem_setup_path!(name, executable: name)
 | 
			
		||||
    install_gem!(name)
 | 
			
		||||
 | 
			
		||||
    return if which(executable)
 | 
			
		||||
 | 
			
		||||
    odie <<~EOS
 | 
			
		||||
      The '#{name}' gem is installed but couldn't find '#{executable}' in the PATH:
 | 
			
		||||
      #{ENV["PATH"]}
 | 
			
		||||
    EOS
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install_bundler!
 | 
			
		||||
    install_gem_setup_path! "bundler", executable: "bundle"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install_bundler_gems!
 | 
			
		||||
    install_bundler!
 | 
			
		||||
    ENV["BUNDLE_GEMFILE"] = "#{HOMEBREW_LIBRARY_PATH}/test/Gemfile"
 | 
			
		||||
    system "bundle", "install" unless quiet_system("bundle", "check")
 | 
			
		||||
    setup_gem_environment!
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # rubocop:disable Style/GlobalVars
 | 
			
		||||
  def inject_dump_stats!(the_module, pattern)
 | 
			
		||||
    @injected_dump_stat_modules ||= {}
 | 
			
		||||
@ -491,9 +428,7 @@ end
 | 
			
		||||
# shortfall or overrun may vary.
 | 
			
		||||
def truncate_text_to_approximate_size(s, max_bytes, options = {})
 | 
			
		||||
  front_weight = options.fetch(:front_weight, 0.5)
 | 
			
		||||
  if front_weight < 0.0 || front_weight > 1.0
 | 
			
		||||
    raise "opts[:front_weight] must be between 0.0 and 1.0"
 | 
			
		||||
  end
 | 
			
		||||
  raise "opts[:front_weight] must be between 0.0 and 1.0" if front_weight < 0.0 || front_weight > 1.0
 | 
			
		||||
  return s if s.bytesize <= max_bytes
 | 
			
		||||
 | 
			
		||||
  glue = "\n[...snip...]\n"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										79
									
								
								Library/Homebrew/utils/gems.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								Library/Homebrew/utils/gems.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,79 @@
 | 
			
		||||
# Never `require` anything in this file (except English). It needs to be able to
 | 
			
		||||
# work as the first item in `brew.rb` so we can load gems with Bundler when
 | 
			
		||||
# needed before anything else is loaded (e.g. `json`).
 | 
			
		||||
 | 
			
		||||
require "English"
 | 
			
		||||
 | 
			
		||||
module Homebrew
 | 
			
		||||
  module_function
 | 
			
		||||
 | 
			
		||||
  def ruby_bindir
 | 
			
		||||
    "#{RbConfig::CONFIG["prefix"]}/bin"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def setup_gem_environment!
 | 
			
		||||
    # Match where our bundler gems are.
 | 
			
		||||
    ENV["GEM_HOME"] = "#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/vendor/bundle/ruby/#{RbConfig::CONFIG["ruby_version"]}"
 | 
			
		||||
    ENV["GEM_PATH"] = ENV["GEM_HOME"]
 | 
			
		||||
 | 
			
		||||
    # Make RubyGems notice environment changes.
 | 
			
		||||
    Gem.clear_paths
 | 
			
		||||
    Gem::Specification.reset
 | 
			
		||||
 | 
			
		||||
    # Add necessary Ruby and Gem binary directories to PATH.
 | 
			
		||||
    paths = ENV["PATH"].split(":")
 | 
			
		||||
    paths.unshift(ruby_bindir) unless paths.include?(ruby_bindir)
 | 
			
		||||
    paths.unshift(Gem.bindir) unless paths.include?(Gem.bindir)
 | 
			
		||||
    ENV["PATH"] = paths.compact.join(":")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install_gem!(name, version = nil)
 | 
			
		||||
    setup_gem_environment!
 | 
			
		||||
    return unless Gem::Specification.find_all_by_name(name, version).empty?
 | 
			
		||||
 | 
			
		||||
    # Shell out to `gem` to avoid RubyGems requires e.g. loading JSON.
 | 
			
		||||
    puts "==> Installing '#{name}' gem"
 | 
			
		||||
    install_args = %W[--no-document #{name}]
 | 
			
		||||
    install_args << "--version" << version if version
 | 
			
		||||
    return if system "#{ruby_bindir}/gem", "install", *install_args
 | 
			
		||||
 | 
			
		||||
    $stderr.puts "Error: failed to install the '#{name}' gem."
 | 
			
		||||
    exit 1
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install_gem_setup_path!(name, executable: name)
 | 
			
		||||
    install_gem!(name)
 | 
			
		||||
    return if ENV["PATH"].split(":").any? do |path|
 | 
			
		||||
      File.executable?("#{path}/#{executable}")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    $stderr.puts <<~EOS
 | 
			
		||||
      Error: the '#{name}' gem is installed but couldn't find '#{executable}' in the PATH:
 | 
			
		||||
      #{ENV["PATH"]}
 | 
			
		||||
    EOS
 | 
			
		||||
    exit 1
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install_bundler!
 | 
			
		||||
    install_gem_setup_path! "bundler", executable: "bundle"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install_bundler_gems!
 | 
			
		||||
    install_bundler!
 | 
			
		||||
 | 
			
		||||
    ENV["BUNDLE_GEMFILE"] = "#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/Gemfile"
 | 
			
		||||
    @bundle_installed ||= begin
 | 
			
		||||
      bundle_check_output = `#{Gem.bindir}/bundle check`
 | 
			
		||||
      bundle_check_failed = !$CHILD_STATUS.exitstatus.zero?
 | 
			
		||||
 | 
			
		||||
      # for some reason sometimes the exit code lies so check the output too.
 | 
			
		||||
      if bundle_check_failed || bundle_check_output.include?("Install missing gems")
 | 
			
		||||
        system "#{Gem.bindir}/bundle", "install"
 | 
			
		||||
      else
 | 
			
		||||
        true
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    setup_gem_environment!
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@ -185,9 +185,7 @@ module GitHub
 | 
			
		||||
        data_tmpfile.close
 | 
			
		||||
        args += ["--data", "@#{data_tmpfile.path}"]
 | 
			
		||||
 | 
			
		||||
        if request_method
 | 
			
		||||
          args += ["--request", request_method.to_s]
 | 
			
		||||
        end
 | 
			
		||||
        args += ["--request", request_method.to_s] if request_method
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      args += ["--dump-header", headers_tmpfile.path]
 | 
			
		||||
@ -206,9 +204,7 @@ module GitHub
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    begin
 | 
			
		||||
      if !http_code.start_with?("2") || !status.success?
 | 
			
		||||
        raise_api_error(output, errors, http_code, headers, scopes)
 | 
			
		||||
      end
 | 
			
		||||
      raise_api_error(output, errors, http_code, headers, scopes) if !http_code.start_with?("2") || !status.success?
 | 
			
		||||
 | 
			
		||||
      return if http_code == "204" # No Content
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -62,9 +62,7 @@ module Tty
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def to_s
 | 
			
		||||
    if !ENV["HOMEBREW_COLOR"] && (ENV["HOMEBREW_NO_COLOR"] || !$stdout.tty?)
 | 
			
		||||
      return ""
 | 
			
		||||
    end
 | 
			
		||||
    return "" if !ENV["HOMEBREW_COLOR"] && (ENV["HOMEBREW_NO_COLOR"] || !$stdout.tty?)
 | 
			
		||||
 | 
			
		||||
    current_escape_sequence
 | 
			
		||||
  ensure
 | 
			
		||||
 | 
			
		||||
@ -7,6 +7,7 @@ class User < DelegateClass(String)
 | 
			
		||||
  def gui?
 | 
			
		||||
    out, _, status = system_command "who"
 | 
			
		||||
    return false unless status.success?
 | 
			
		||||
 | 
			
		||||
    out.lines
 | 
			
		||||
       .map(&:split)
 | 
			
		||||
       .any? { |user, type,| user == self && type == "console" }
 | 
			
		||||
 | 
			
		||||
@ -206,9 +206,7 @@ class Version
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.create(val)
 | 
			
		||||
    unless val.respond_to?(:to_str)
 | 
			
		||||
      raise TypeError, "Version value must be a string; got a #{val.class} (#{val})"
 | 
			
		||||
    end
 | 
			
		||||
    raise TypeError, "Version value must be a string; got a #{val.class} (#{val})" unless val.respond_to?(:to_str)
 | 
			
		||||
 | 
			
		||||
    if val.to_str.start_with?("HEAD")
 | 
			
		||||
      HeadVersion.new(val)
 | 
			
		||||
@ -365,9 +363,7 @@ class Version
 | 
			
		||||
  private_class_method :_parse
 | 
			
		||||
 | 
			
		||||
  def initialize(val)
 | 
			
		||||
    unless val.respond_to?(:to_str)
 | 
			
		||||
      raise TypeError, "Version value must be a string; got a #{val.class} (#{val})"
 | 
			
		||||
    end
 | 
			
		||||
    raise TypeError, "Version value must be a string; got a #{val.class} (#{val})" unless val.respond_to?(:to_str)
 | 
			
		||||
 | 
			
		||||
    @version = val.to_str
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user