Merge pull request #1113 from reitermarkus/rubocop-guardclause
RuboCop: Fix Style/GuardClause.
This commit is contained in:
		
						commit
						e2c7509065
					
				@ -118,43 +118,6 @@ Style/GlobalVars:
 | 
			
		||||
    - 'Homebrew/diagnostic.rb'
 | 
			
		||||
    - 'Homebrew/utils.rb'
 | 
			
		||||
 | 
			
		||||
# Offense count: 70
 | 
			
		||||
# Configuration parameters: MinBodyLength.
 | 
			
		||||
Style/GuardClause:
 | 
			
		||||
  Exclude:
 | 
			
		||||
    - 'Taps/**/*'
 | 
			
		||||
    - 'Homebrew/cmd/update-report.rb'
 | 
			
		||||
    - 'Homebrew/dependency_collector.rb'
 | 
			
		||||
    - 'Homebrew/dev-cmd/audit.rb'
 | 
			
		||||
    - 'Homebrew/dev-cmd/pull.rb'
 | 
			
		||||
    - 'Homebrew/dev-cmd/test-bot.rb'
 | 
			
		||||
    - 'Homebrew/download_strategy.rb'
 | 
			
		||||
    - 'Homebrew/extend/ARGV.rb'
 | 
			
		||||
    - 'Homebrew/extend/ENV/shared.rb'
 | 
			
		||||
    - 'Homebrew/extend/ENV/std.rb'
 | 
			
		||||
    - 'Homebrew/extend/ENV/super.rb'
 | 
			
		||||
    - 'Homebrew/extend/fileutils.rb'
 | 
			
		||||
    - 'Homebrew/extend/os/mac/extend/ENV/std.rb'
 | 
			
		||||
    - 'Homebrew/extend/os/mac/formula_cellar_checks.rb'
 | 
			
		||||
    - 'Homebrew/extend/os/mac/utils/bottles.rb'
 | 
			
		||||
    - 'Homebrew/extend/string.rb'
 | 
			
		||||
    - 'Homebrew/formula.rb'
 | 
			
		||||
    - 'Homebrew/formula_installer.rb'
 | 
			
		||||
    - 'Homebrew/formula_lock.rb'
 | 
			
		||||
    - 'Homebrew/formulary.rb'
 | 
			
		||||
    - 'Homebrew/keg.rb'
 | 
			
		||||
    - 'Homebrew/migrator.rb'
 | 
			
		||||
    - 'Homebrew/os/mac/xcode.rb'
 | 
			
		||||
    - 'Homebrew/patch.rb'
 | 
			
		||||
    - 'Homebrew/requirement.rb'
 | 
			
		||||
    - 'Homebrew/tap.rb'
 | 
			
		||||
    - 'Homebrew/test/test_cmd_testbot.rb'
 | 
			
		||||
    - 'Homebrew/test/test_integration_cmds.rb'
 | 
			
		||||
    - 'Homebrew/test/testing_env.rb'
 | 
			
		||||
    - 'Homebrew/utils.rb'
 | 
			
		||||
    - 'Homebrew/utils/popen.rb'
 | 
			
		||||
    - 'Homebrew/version.rb'
 | 
			
		||||
 | 
			
		||||
# Offense count: 51
 | 
			
		||||
# Cop supports --auto-correct.
 | 
			
		||||
# Configuration parameters: MaxLineLength.
 | 
			
		||||
 | 
			
		||||
@ -203,13 +203,12 @@ module Homebrew
 | 
			
		||||
        # If they haven't updated in 48 hours (172800 seconds), that
 | 
			
		||||
        # might explain the error
 | 
			
		||||
        master = HOMEBREW_REPOSITORY/".git/refs/heads/master"
 | 
			
		||||
        if master.exist? && (Time.now.to_i - File.mtime(master).to_i) > 172800
 | 
			
		||||
          ohai "You haven't updated Homebrew in a while."
 | 
			
		||||
          puts <<-EOS.undent
 | 
			
		||||
            A formula for #{e.name} might have been added recently.
 | 
			
		||||
            Run `brew update` to get the latest Homebrew updates!
 | 
			
		||||
          EOS
 | 
			
		||||
        end
 | 
			
		||||
        return unless master.exist? && (Time.now.to_i - File.mtime(master).to_i) > 172800
 | 
			
		||||
        ohai "You haven't updated Homebrew in a while."
 | 
			
		||||
        puts <<-EOS.undent
 | 
			
		||||
          A formula for #{e.name} might have been added recently.
 | 
			
		||||
          Run `brew update` to get the latest Homebrew updates!
 | 
			
		||||
        EOS
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -549,11 +549,10 @@ class ReporterHub
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless formulae.empty?
 | 
			
		||||
      # Dump formula list.
 | 
			
		||||
      ohai title
 | 
			
		||||
      puts_columns(formulae)
 | 
			
		||||
    end
 | 
			
		||||
    return if formulae.empty?
 | 
			
		||||
    # Dump formula list.
 | 
			
		||||
    ohai title
 | 
			
		||||
    puts_columns(formulae)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def installed?(formula)
 | 
			
		||||
 | 
			
		||||
@ -128,11 +128,11 @@ class DependencyCollector
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def parse_class_spec(spec, tags)
 | 
			
		||||
    if spec < Requirement
 | 
			
		||||
      spec.new(tags)
 | 
			
		||||
    else
 | 
			
		||||
    unless spec < Requirement
 | 
			
		||||
      raise TypeError, "#{spec.inspect} is not a Requirement subclass"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    spec.new(tags)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def ant_dep(spec, tags)
 | 
			
		||||
 | 
			
		||||
@ -284,9 +284,8 @@ class FormulaAuditor
 | 
			
		||||
      problem "Should not have both `head` and `head do`"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if present.include?("bottle modifier") && present.include?("bottle block")
 | 
			
		||||
      problem "Should not have `bottle :unneeded/:disable` and `bottle do`"
 | 
			
		||||
    end
 | 
			
		||||
    return unless present.include?("bottle modifier") && present.include?("bottle block")
 | 
			
		||||
    problem "Should not have `bottle :unneeded/:disable` and `bottle do`"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_class
 | 
			
		||||
@ -350,9 +349,8 @@ class FormulaAuditor
 | 
			
		||||
 | 
			
		||||
    same_name_tap_formulae.delete(full_name)
 | 
			
		||||
 | 
			
		||||
    unless same_name_tap_formulae.empty?
 | 
			
		||||
      problem "Formula name conflicts with #{same_name_tap_formulae.join ", "}"
 | 
			
		||||
    end
 | 
			
		||||
    return if same_name_tap_formulae.empty?
 | 
			
		||||
    problem "Formula name conflicts with #{same_name_tap_formulae.join ", "}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_deps
 | 
			
		||||
@ -485,9 +483,8 @@ class FormulaAuditor
 | 
			
		||||
      problem "Description shouldn't start with an indefinite article (#{$1})"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if desc.downcase.start_with? "#{formula.name} "
 | 
			
		||||
      problem "Description shouldn't include the formula name"
 | 
			
		||||
    end
 | 
			
		||||
    return unless desc.downcase.start_with? "#{formula.name} "
 | 
			
		||||
    problem "Description shouldn't include the formula name"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_homepage
 | 
			
		||||
@ -564,9 +561,9 @@ class FormulaAuditor
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_bottle_spec
 | 
			
		||||
    if formula.bottle_disabled? && !formula.bottle_disable_reason.valid?
 | 
			
		||||
      problem "Unrecognized bottle modifier"
 | 
			
		||||
    end
 | 
			
		||||
    return unless formula.bottle_disabled?
 | 
			
		||||
    return if formula.bottle_disable_reason.valid?
 | 
			
		||||
    problem "Unrecognized bottle modifier"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_github_repository
 | 
			
		||||
@ -594,9 +591,8 @@ class FormulaAuditor
 | 
			
		||||
      problem "GitHub repository not notable enough (<20 forks, <20 watchers and <50 stars)"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if Date.parse(metadata["created_at"]) > (Date.today - 30)
 | 
			
		||||
      problem "GitHub repository too new (<30 days old)"
 | 
			
		||||
    end
 | 
			
		||||
    return if Date.parse(metadata["created_at"]) <= (Date.today - 30)
 | 
			
		||||
    problem "GitHub repository too new (<30 days old)"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_specs
 | 
			
		||||
@ -736,9 +732,8 @@ class FormulaAuditor
 | 
			
		||||
      problem "Please set plist_options when using a formula-defined plist."
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if text.include?('require "language/go"') && !text.include?("go_resource")
 | 
			
		||||
      problem "require \"language/go\" is unnecessary unless using `go_resource`s"
 | 
			
		||||
    end
 | 
			
		||||
    return unless text.include?('require "language/go"') && !text.include?("go_resource")
 | 
			
		||||
    problem "require \"language/go\" is unnecessary unless using `go_resource`s"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_line(line, lineno)
 | 
			
		||||
@ -983,9 +978,8 @@ class FormulaAuditor
 | 
			
		||||
      problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
 | 
			
		||||
      problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
 | 
			
		||||
    end
 | 
			
		||||
    return unless line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
 | 
			
		||||
    problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_caveats
 | 
			
		||||
@ -1115,9 +1109,8 @@ class ResourceAuditor
 | 
			
		||||
      problem "version #{version} should not have a leading 'v'"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if version.to_s =~ /_\d+$/
 | 
			
		||||
      problem "version #{version} should not end with an underline and a number"
 | 
			
		||||
    end
 | 
			
		||||
    return unless version.to_s =~ /_\d+$/
 | 
			
		||||
    problem "version #{version} should not end with an underline and a number"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_checksum
 | 
			
		||||
@ -1183,9 +1176,8 @@ class ResourceAuditor
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if url_strategy == DownloadStrategyDetector.detect("", using)
 | 
			
		||||
      problem "Redundant :using value in URL"
 | 
			
		||||
    end
 | 
			
		||||
    return unless url_strategy == DownloadStrategyDetector.detect("", using)
 | 
			
		||||
    problem "Redundant :using value in URL"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_urls
 | 
			
		||||
 | 
			
		||||
@ -531,19 +531,19 @@ module Homebrew
 | 
			
		||||
            req = Net::HTTP::Head.new bottle_info.url
 | 
			
		||||
            req.initialize_http_header "User-Agent" => HOMEBREW_USER_AGENT_RUBY
 | 
			
		||||
            res = http.request req
 | 
			
		||||
            if res.is_a?(Net::HTTPSuccess)
 | 
			
		||||
              break
 | 
			
		||||
            elsif res.is_a?(Net::HTTPClientError)
 | 
			
		||||
              if retry_count >= max_retries
 | 
			
		||||
                raise "Failed to find published #{f} bottle at #{url}!"
 | 
			
		||||
              end
 | 
			
		||||
              print(wrote_dots ? "." : "Waiting on Bintray.")
 | 
			
		||||
              wrote_dots = true
 | 
			
		||||
              sleep poll_retry_delay_seconds
 | 
			
		||||
              retry_count += 1
 | 
			
		||||
            else
 | 
			
		||||
            break if res.is_a?(Net::HTTPSuccess)
 | 
			
		||||
 | 
			
		||||
            unless res.is_a?(Net::HTTPClientError)
 | 
			
		||||
              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
 | 
			
		||||
            print(wrote_dots ? "." : "Waiting on Bintray.")
 | 
			
		||||
            wrote_dots = true
 | 
			
		||||
            sleep poll_retry_delay_seconds
 | 
			
		||||
            retry_count += 1
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -123,13 +123,12 @@ module Homebrew
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"]
 | 
			
		||||
      # Also can get tap from Jenkins GIT_URL.
 | 
			
		||||
      url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/").sub(/\.git$/, "")
 | 
			
		||||
      begin
 | 
			
		||||
        return Tap.fetch(url_path) if url_path =~ HOMEBREW_TAP_REGEX
 | 
			
		||||
      rescue
 | 
			
		||||
      end
 | 
			
		||||
    return unless git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"]
 | 
			
		||||
    # Also can get tap from Jenkins GIT_URL.
 | 
			
		||||
    url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/").sub(/\.git$/, "")
 | 
			
		||||
    begin
 | 
			
		||||
      return Tap.fetch(url_path) if url_path =~ HOMEBREW_TAP_REGEX
 | 
			
		||||
    rescue
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -1001,10 +1000,9 @@ module Homebrew
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if git_tag
 | 
			
		||||
      safe_system "git", "tag", "--force", git_tag
 | 
			
		||||
      safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}"
 | 
			
		||||
    end
 | 
			
		||||
    return unless git_tag
 | 
			
		||||
    safe_system "git", "tag", "--force", git_tag
 | 
			
		||||
    safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def sanitize_argv_and_env
 | 
			
		||||
@ -1053,13 +1051,12 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
    ARGV << "--fast" if ARGV.include?("--ci-master")
 | 
			
		||||
 | 
			
		||||
    if ARGV.include? "--local"
 | 
			
		||||
      ENV["HOMEBREW_CACHE"] = "#{ENV["HOME"]}/Library/Caches/Homebrew"
 | 
			
		||||
      mkdir_p ENV["HOMEBREW_CACHE"]
 | 
			
		||||
      ENV["HOMEBREW_HOME"] = ENV["HOME"] = "#{Dir.pwd}/home"
 | 
			
		||||
      mkdir_p ENV["HOME"]
 | 
			
		||||
      ENV["HOMEBREW_LOGS"] = "#{Dir.pwd}/logs"
 | 
			
		||||
    end
 | 
			
		||||
    return unless ARGV.include?("--local")
 | 
			
		||||
    ENV["HOMEBREW_CACHE"] = "#{ENV["HOME"]}/Library/Caches/Homebrew"
 | 
			
		||||
    mkdir_p ENV["HOMEBREW_CACHE"]
 | 
			
		||||
    ENV["HOMEBREW_HOME"] = ENV["HOME"] = "#{Dir.pwd}/home"
 | 
			
		||||
    mkdir_p ENV["HOME"]
 | 
			
		||||
    ENV["HOMEBREW_LOGS"] = "#{Dir.pwd}/logs"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_bot
 | 
			
		||||
 | 
			
		||||
@ -158,14 +158,13 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
 | 
			
		||||
 | 
			
		||||
    version.update_commit(last_commit) if head?
 | 
			
		||||
 | 
			
		||||
    if @ref_type == :tag && @revision && current_revision
 | 
			
		||||
      unless current_revision == @revision
 | 
			
		||||
        raise <<-EOS.undent
 | 
			
		||||
          #{@ref} tag should be #{@revision}
 | 
			
		||||
          but is actually #{current_revision}
 | 
			
		||||
        EOS
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    return unless @ref_type == :tag
 | 
			
		||||
    return unless @revision && current_revision
 | 
			
		||||
    return if current_revision == @revision
 | 
			
		||||
    raise <<-EOS.undent
 | 
			
		||||
      #{@ref} tag should be #{@revision}
 | 
			
		||||
      but is actually #{current_revision}
 | 
			
		||||
    EOS
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def fetch_last_commit
 | 
			
		||||
@ -336,14 +335,14 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
 | 
			
		||||
      rescue ErrorDuringExecution
 | 
			
		||||
        # 33 == range not supported
 | 
			
		||||
        # try wiping the incomplete download and retrying once
 | 
			
		||||
        if $?.exitstatus == 33 && had_incomplete_download
 | 
			
		||||
          ohai "Trying a full download"
 | 
			
		||||
          temporary_path.unlink
 | 
			
		||||
          had_incomplete_download = false
 | 
			
		||||
          retry
 | 
			
		||||
        else
 | 
			
		||||
        unless $?.exitstatus == 33 && had_incomplete_download
 | 
			
		||||
          raise CurlDownloadStrategyError, @url
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        ohai "Trying a full download"
 | 
			
		||||
        temporary_path.unlink
 | 
			
		||||
        had_incomplete_download = false
 | 
			
		||||
        retry
 | 
			
		||||
      end
 | 
			
		||||
      ignore_interrupts { temporary_path.rename(cached_location) }
 | 
			
		||||
    end
 | 
			
		||||
@ -717,12 +716,12 @@ class GitDownloadStrategy < VCSDownloadStrategy
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def update_repo
 | 
			
		||||
    if @ref_type == :branch || !ref?
 | 
			
		||||
      if !shallow_clone? && shallow_dir?
 | 
			
		||||
        quiet_safe_system "git", "fetch", "origin", "--unshallow"
 | 
			
		||||
      else
 | 
			
		||||
        quiet_safe_system "git", "fetch", "origin"
 | 
			
		||||
      end
 | 
			
		||||
    return unless @ref_type == :branch || !ref?
 | 
			
		||||
 | 
			
		||||
    if !shallow_clone? && shallow_dir?
 | 
			
		||||
      quiet_safe_system "git", "fetch", "origin", "--unshallow"
 | 
			
		||||
    else
 | 
			
		||||
      quiet_safe_system "git", "fetch", "origin"
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -798,10 +797,10 @@ end
 | 
			
		||||
class GitHubGitDownloadStrategy < GitDownloadStrategy
 | 
			
		||||
  def initialize(name, resource)
 | 
			
		||||
    super
 | 
			
		||||
    if @url =~ %r{^https?://github\.com/([^/]+)/([^/]+)\.git$}
 | 
			
		||||
      @user = $1
 | 
			
		||||
      @repo = $2
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return unless %r{^https?://github\.com/(?<user>[^/]+)/(?<repo>[^/]+)\.git$} =~ @url
 | 
			
		||||
    @user = user
 | 
			
		||||
    @repo = repo
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def github_last_commit
 | 
			
		||||
 | 
			
		||||
@ -88,11 +88,11 @@ module HomebrewArgvExtension
 | 
			
		||||
            Formulary.from_rack(rack)
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          if (prefix = f.installed_prefix).directory?
 | 
			
		||||
            Keg.new(prefix)
 | 
			
		||||
          else
 | 
			
		||||
          unless (prefix = f.installed_prefix).directory?
 | 
			
		||||
            raise MultipleVersionsInstalledError, rack.basename
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          Keg.new(prefix)
 | 
			
		||||
        end
 | 
			
		||||
      rescue FormulaUnavailableError
 | 
			
		||||
        raise <<-EOS.undent
 | 
			
		||||
 | 
			
		||||
@ -289,12 +289,11 @@ module SharedEnvExtension
 | 
			
		||||
      EOS
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless gcc_formula.opt_prefix.exist?
 | 
			
		||||
      raise <<-EOS.undent
 | 
			
		||||
      The requested Homebrew GCC was not installed. You must:
 | 
			
		||||
        brew install #{gcc_formula.full_name}
 | 
			
		||||
      EOS
 | 
			
		||||
    end
 | 
			
		||||
    return if gcc_formula.opt_prefix.exist?
 | 
			
		||||
    raise <<-EOS.undent
 | 
			
		||||
    The requested Homebrew GCC was not installed. You must:
 | 
			
		||||
      brew install #{gcc_formula.full_name}
 | 
			
		||||
    EOS
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def permit_arch_flags; end
 | 
			
		||||
@ -328,9 +327,8 @@ module SharedEnvExtension
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def check_for_compiler_universal_support
 | 
			
		||||
    if homebrew_cc =~ GNU_GCC_REGEXP
 | 
			
		||||
      raise "Non-Apple GCC can't build universal binaries"
 | 
			
		||||
    end
 | 
			
		||||
    return unless homebrew_cc =~ GNU_GCC_REGEXP
 | 
			
		||||
    raise "Non-Apple GCC can't build universal binaries"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def gcc_with_cxx11_support?(cc)
 | 
			
		||||
 | 
			
		||||
@ -48,10 +48,9 @@ module Stdenv
 | 
			
		||||
 | 
			
		||||
    send(compiler)
 | 
			
		||||
 | 
			
		||||
    if cc =~ GNU_GCC_REGEXP
 | 
			
		||||
      gcc_formula = gcc_version_formula($&)
 | 
			
		||||
      append_path "PATH", gcc_formula.opt_bin.to_s
 | 
			
		||||
    end
 | 
			
		||||
    return unless cc =~ GNU_GCC_REGEXP
 | 
			
		||||
    gcc_formula = gcc_version_formula($&)
 | 
			
		||||
    append_path "PATH", gcc_formula.opt_bin.to_s
 | 
			
		||||
  end
 | 
			
		||||
  alias generic_setup_build_environment setup_build_environment
 | 
			
		||||
 | 
			
		||||
@ -174,10 +173,10 @@ module Stdenv
 | 
			
		||||
    append_to_cflags Hardware::CPU.universal_archs.as_arch_flags
 | 
			
		||||
    append "LDFLAGS", Hardware::CPU.universal_archs.as_arch_flags
 | 
			
		||||
 | 
			
		||||
    if compiler != :clang && Hardware.is_32_bit?
 | 
			
		||||
      # Can't mix "-march" for a 32-bit CPU  with "-arch x86_64"
 | 
			
		||||
      replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
 | 
			
		||||
    end
 | 
			
		||||
    return if compiler == :clang
 | 
			
		||||
    return unless Hardware.is_32_bit?
 | 
			
		||||
    # Can't mix "-march" for a 32-bit CPU  with "-arch x86_64"
 | 
			
		||||
    replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def cxx11
 | 
			
		||||
 | 
			
		||||
@ -276,12 +276,12 @@ module Superenv
 | 
			
		||||
    self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
 | 
			
		||||
 | 
			
		||||
    # GCC doesn't accept "-march" for a 32-bit CPU with "-arch x86_64"
 | 
			
		||||
    if compiler != :clang && Hardware::CPU.is_32_bit?
 | 
			
		||||
      self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
 | 
			
		||||
        /-march=\S*/,
 | 
			
		||||
        "-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
 | 
			
		||||
      )
 | 
			
		||||
    end
 | 
			
		||||
    return if compiler == :clang
 | 
			
		||||
    return unless Hardware::CPU.is_32_bit?
 | 
			
		||||
    self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
 | 
			
		||||
      /-march=\S*/,
 | 
			
		||||
      "-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
 | 
			
		||||
    )
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def permit_arch_flags
 | 
			
		||||
 | 
			
		||||
@ -89,10 +89,9 @@ module FileUtils
 | 
			
		||||
  # A version of mkdir that also changes to that folder in a block.
 | 
			
		||||
  def mkdir(name, &_block)
 | 
			
		||||
    old_mkdir(name)
 | 
			
		||||
    if block_given?
 | 
			
		||||
      chdir name do
 | 
			
		||||
        yield
 | 
			
		||||
      end
 | 
			
		||||
    return unless block_given?
 | 
			
		||||
    chdir name do
 | 
			
		||||
      yield
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  module_function :mkdir
 | 
			
		||||
 | 
			
		||||
@ -20,14 +20,13 @@ module Stdenv
 | 
			
		||||
 | 
			
		||||
    # Leopard's ld needs some convincing that it's building 64-bit
 | 
			
		||||
    # See: https://github.com/mistydemeo/tigerbrew/issues/59
 | 
			
		||||
    if MacOS.version == :leopard && MacOS.prefer_64_bit?
 | 
			
		||||
      append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}"
 | 
			
		||||
    return unless MacOS.version == :leopard && MacOS.prefer_64_bit?
 | 
			
		||||
    append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}"
 | 
			
		||||
 | 
			
		||||
      # Many, many builds are broken thanks to Leopard's buggy ld.
 | 
			
		||||
      # Our ld64 fixes many of those builds, though of course we can't
 | 
			
		||||
      # depend on it already being installed to build itself.
 | 
			
		||||
      ld64 if Formula["ld64"].installed?
 | 
			
		||||
    end
 | 
			
		||||
    # Many, many builds are broken thanks to Leopard's buggy ld.
 | 
			
		||||
    # Our ld64 fixes many of those builds, though of course we can't
 | 
			
		||||
    # depend on it already being installed to build itself.
 | 
			
		||||
    ld64 if Formula["ld64"].installed?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def homebrew_extra_pkg_config_paths
 | 
			
		||||
@ -65,19 +64,18 @@ module Stdenv
 | 
			
		||||
    delete("CPATH")
 | 
			
		||||
    remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
 | 
			
		||||
 | 
			
		||||
    if (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
 | 
			
		||||
      delete("SDKROOT")
 | 
			
		||||
      remove_from_cflags "-isysroot #{sdk}"
 | 
			
		||||
      remove "CPPFLAGS", "-isysroot #{sdk}"
 | 
			
		||||
      remove "LDFLAGS", "-isysroot #{sdk}"
 | 
			
		||||
      if HOMEBREW_PREFIX.to_s == "/usr/local"
 | 
			
		||||
        delete("CMAKE_PREFIX_PATH")
 | 
			
		||||
      else
 | 
			
		||||
        # It was set in setup_build_environment, so we have to restore it here.
 | 
			
		||||
        self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
 | 
			
		||||
      end
 | 
			
		||||
      remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
 | 
			
		||||
    return unless (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
 | 
			
		||||
    delete("SDKROOT")
 | 
			
		||||
    remove_from_cflags "-isysroot #{sdk}"
 | 
			
		||||
    remove "CPPFLAGS", "-isysroot #{sdk}"
 | 
			
		||||
    remove "LDFLAGS", "-isysroot #{sdk}"
 | 
			
		||||
    if HOMEBREW_PREFIX.to_s == "/usr/local"
 | 
			
		||||
      delete("CMAKE_PREFIX_PATH")
 | 
			
		||||
    else
 | 
			
		||||
      # It was set in setup_build_environment, so we have to restore it here.
 | 
			
		||||
      self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
 | 
			
		||||
    end
 | 
			
		||||
    remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def macosxsdk(version = MacOS.version)
 | 
			
		||||
@ -89,20 +87,19 @@ module Stdenv
 | 
			
		||||
    self["CPATH"] = "#{HOMEBREW_PREFIX}/include"
 | 
			
		||||
    prepend "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
 | 
			
		||||
 | 
			
		||||
    if (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
 | 
			
		||||
      # Extra setup to support Xcode 4.3+ without CLT.
 | 
			
		||||
      self["SDKROOT"] = sdk
 | 
			
		||||
      # Tell clang/gcc where system include's are:
 | 
			
		||||
      append_path "CPATH", "#{sdk}/usr/include"
 | 
			
		||||
      # The -isysroot is needed, too, because of the Frameworks
 | 
			
		||||
      append_to_cflags "-isysroot #{sdk}"
 | 
			
		||||
      append "CPPFLAGS", "-isysroot #{sdk}"
 | 
			
		||||
      # And the linker needs to find sdk/usr/lib
 | 
			
		||||
      append "LDFLAGS", "-isysroot #{sdk}"
 | 
			
		||||
      # Needed to build cmake itself and perhaps some cmake projects:
 | 
			
		||||
      append_path "CMAKE_PREFIX_PATH", "#{sdk}/usr"
 | 
			
		||||
      append_path "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
 | 
			
		||||
    end
 | 
			
		||||
    return unless (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
 | 
			
		||||
    # Extra setup to support Xcode 4.3+ without CLT.
 | 
			
		||||
    self["SDKROOT"] = sdk
 | 
			
		||||
    # Tell clang/gcc where system include's are:
 | 
			
		||||
    append_path "CPATH", "#{sdk}/usr/include"
 | 
			
		||||
    # The -isysroot is needed, too, because of the Frameworks
 | 
			
		||||
    append_to_cflags "-isysroot #{sdk}"
 | 
			
		||||
    append "CPPFLAGS", "-isysroot #{sdk}"
 | 
			
		||||
    # And the linker needs to find sdk/usr/lib
 | 
			
		||||
    append "LDFLAGS", "-isysroot #{sdk}"
 | 
			
		||||
    # Needed to build cmake itself and perhaps some cmake projects:
 | 
			
		||||
    append_path "CMAKE_PREFIX_PATH", "#{sdk}/usr"
 | 
			
		||||
    append_path "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Some configure scripts won't find libxml2 without help
 | 
			
		||||
 | 
			
		||||
@ -64,13 +64,12 @@ module FormulaCellarChecks
 | 
			
		||||
    keg = Keg.new(formula.prefix)
 | 
			
		||||
    checker = LinkageChecker.new(keg, formula)
 | 
			
		||||
 | 
			
		||||
    if checker.broken_dylibs?
 | 
			
		||||
      audit_check_output <<-EOS.undent
 | 
			
		||||
        The installation was broken.
 | 
			
		||||
        Broken dylib links found:
 | 
			
		||||
          #{checker.broken_dylibs.to_a * "\n          "}
 | 
			
		||||
      EOS
 | 
			
		||||
    end
 | 
			
		||||
    return unless checker.broken_dylibs?
 | 
			
		||||
    audit_check_output <<-EOS.undent
 | 
			
		||||
      The installation was broken.
 | 
			
		||||
      Broken dylib links found:
 | 
			
		||||
        #{checker.broken_dylibs.to_a * "\n          "}
 | 
			
		||||
    EOS
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_installed
 | 
			
		||||
 | 
			
		||||
@ -31,10 +31,9 @@ module Utils
 | 
			
		||||
      # sometimes a formula has just :tiger_altivec, other times it has
 | 
			
		||||
      # :tiger_g4, :tiger_g5, etc.
 | 
			
		||||
      def find_altivec_tag(tag)
 | 
			
		||||
        if tag.to_s =~ /(\w+)_(g4|g4e|g5)$/
 | 
			
		||||
          altivec_tag = "#{$1}_altivec".to_sym
 | 
			
		||||
          altivec_tag if key?(altivec_tag)
 | 
			
		||||
        end
 | 
			
		||||
        return unless tag.to_s =~ /(\w+)_(g4|g4e|g5)$/
 | 
			
		||||
        altivec_tag = "#{$1}_altivec".to_sym
 | 
			
		||||
        altivec_tag if key?(altivec_tag)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      # Allows a bottle tag to specify a specific OS or later,
 | 
			
		||||
 | 
			
		||||
@ -59,9 +59,8 @@ module StringInreplaceExtension
 | 
			
		||||
  # Looks for Makefile style variable defintions and replaces the
 | 
			
		||||
  # value with "new_value", or removes the definition entirely.
 | 
			
		||||
  def change_make_var!(flag, new_value)
 | 
			
		||||
    unless gsub!(/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
 | 
			
		||||
      errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
 | 
			
		||||
    end
 | 
			
		||||
    return if gsub!(/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
 | 
			
		||||
    errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Removes variable assignments completely.
 | 
			
		||||
 | 
			
		||||
@ -224,10 +224,9 @@ class Formula
 | 
			
		||||
 | 
			
		||||
  def set_spec(name)
 | 
			
		||||
    spec = self.class.send(name)
 | 
			
		||||
    if spec.url
 | 
			
		||||
      spec.owner = self
 | 
			
		||||
      instance_variable_set("@#{name}", spec)
 | 
			
		||||
    end
 | 
			
		||||
    return unless spec.url
 | 
			
		||||
    spec.owner = self
 | 
			
		||||
    instance_variable_set("@#{name}", spec)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def determine_active_spec(requested)
 | 
			
		||||
@ -246,9 +245,8 @@ class Formula
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    val = version.respond_to?(:to_str) ? version.to_str : version
 | 
			
		||||
    if val.nil? || val.empty? || val =~ /\s/
 | 
			
		||||
      raise FormulaValidationError.new(full_name, :version, val)
 | 
			
		||||
    end
 | 
			
		||||
    return unless val.nil? || val.empty? || val =~ /\s/
 | 
			
		||||
    raise FormulaValidationError.new(full_name, :version, val)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  public
 | 
			
		||||
@ -1065,10 +1063,9 @@ class Formula
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def patch
 | 
			
		||||
    unless patchlist.empty?
 | 
			
		||||
      ohai "Patching"
 | 
			
		||||
      patchlist.each(&:apply)
 | 
			
		||||
    end
 | 
			
		||||
    return if patchlist.empty?
 | 
			
		||||
    ohai "Patching"
 | 
			
		||||
    patchlist.each(&:apply)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # yields |self,staging| with current working directory set to the uncompressed tarball
 | 
			
		||||
@ -1094,10 +1091,11 @@ class Formula
 | 
			
		||||
  def lock
 | 
			
		||||
    @lock = FormulaLock.new(name)
 | 
			
		||||
    @lock.lock
 | 
			
		||||
    if oldname && (oldname_rack = HOMEBREW_CELLAR/oldname).exist? && oldname_rack.resolved_path == rack
 | 
			
		||||
      @oldname_lock = FormulaLock.new(oldname)
 | 
			
		||||
      @oldname_lock.lock
 | 
			
		||||
    end
 | 
			
		||||
    return unless oldname
 | 
			
		||||
    return unless (oldname_rack = HOMEBREW_CELLAR/oldname).exist?
 | 
			
		||||
    return unless oldname_rack.resolved_path == rack
 | 
			
		||||
    @oldname_lock = FormulaLock.new(oldname)
 | 
			
		||||
    @oldname_lock.lock
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
@ -1427,10 +1425,9 @@ class Formula
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def print_tap_action(options = {})
 | 
			
		||||
    if tap?
 | 
			
		||||
      verb = options[:verb] || "Installing"
 | 
			
		||||
      ohai "#{verb} #{name} from #{tap}"
 | 
			
		||||
    end
 | 
			
		||||
    return unless tap?
 | 
			
		||||
    verb = options[:verb] || "Installing"
 | 
			
		||||
    ohai "#{verb} #{name} from #{tap}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
 | 
			
		||||
@ -133,12 +133,10 @@ class FormulaInstaller
 | 
			
		||||
    begin
 | 
			
		||||
      compute_dependencies
 | 
			
		||||
    rescue TapFormulaUnavailableError => e
 | 
			
		||||
      if e.tap.installed?
 | 
			
		||||
        raise
 | 
			
		||||
      else
 | 
			
		||||
        e.tap.install
 | 
			
		||||
        retry
 | 
			
		||||
      end
 | 
			
		||||
      raise if e.tap.installed?
 | 
			
		||||
 | 
			
		||||
      e.tap.install
 | 
			
		||||
      retry
 | 
			
		||||
    end
 | 
			
		||||
  rescue FormulaUnavailableError => e
 | 
			
		||||
    e.dependent = formula.full_name
 | 
			
		||||
@ -148,23 +146,24 @@ class FormulaInstaller
 | 
			
		||||
  def check_install_sanity
 | 
			
		||||
    raise FormulaInstallationAlreadyAttemptedError, formula if @@attempted.include?(formula)
 | 
			
		||||
 | 
			
		||||
    unless skip_deps_check?
 | 
			
		||||
      recursive_deps = formula.recursive_dependencies
 | 
			
		||||
      unlinked_deps = recursive_deps.map(&:to_formula).select do |dep|
 | 
			
		||||
        dep.installed? && !dep.keg_only? && !dep.linked_keg.directory?
 | 
			
		||||
      end
 | 
			
		||||
      raise CannotInstallFormulaError,
 | 
			
		||||
        "You must `brew link #{unlinked_deps*" "}` before #{formula.full_name} can be installed" unless unlinked_deps.empty?
 | 
			
		||||
    return if skip_deps_check?
 | 
			
		||||
 | 
			
		||||
      pinned_unsatisfied_deps = recursive_deps.select do |dep|
 | 
			
		||||
        dep.to_formula.pinned? && !dep.satisfied?(inherited_options_for(dep))
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      unless pinned_unsatisfied_deps.empty?
 | 
			
		||||
        raise CannotInstallFormulaError,
 | 
			
		||||
          "You must `brew unpin #{pinned_unsatisfied_deps*" "}` as installing #{formula.full_name} requires the latest version of pinned dependencies"
 | 
			
		||||
      end
 | 
			
		||||
    recursive_deps = formula.recursive_dependencies
 | 
			
		||||
    unlinked_deps = recursive_deps.map(&:to_formula).select do |dep|
 | 
			
		||||
      dep.installed? && !dep.keg_only? && !dep.linked_keg.directory?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless unlinked_deps.empty?
 | 
			
		||||
      raise CannotInstallFormulaError, "You must `brew link #{unlinked_deps*" "}` before #{formula.full_name} can be installed"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    pinned_unsatisfied_deps = recursive_deps.select do |dep|
 | 
			
		||||
      dep.to_formula.pinned? && !dep.satisfied?(inherited_options_for(dep))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return if pinned_unsatisfied_deps.empty?
 | 
			
		||||
    raise CannotInstallFormulaError,
 | 
			
		||||
      "You must `brew unpin #{pinned_unsatisfied_deps*" "}` as installing #{formula.full_name} requires the latest version of pinned dependencies"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def build_bottle_preinstall
 | 
			
		||||
@ -285,11 +284,10 @@ class FormulaInstaller
 | 
			
		||||
          #{formula}: #{e.message}
 | 
			
		||||
          'conflicts_with \"#{c.name}\"' should be removed from #{formula.path.basename}.
 | 
			
		||||
        EOS
 | 
			
		||||
        if ARGV.homebrew_developer?
 | 
			
		||||
          raise
 | 
			
		||||
        else
 | 
			
		||||
          $stderr.puts "Please report this to the #{formula.tap} tap!"
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        raise if ARGV.homebrew_developer?
 | 
			
		||||
 | 
			
		||||
        $stderr.puts "Please report this to the #{formula.tap} tap!"
 | 
			
		||||
        false
 | 
			
		||||
      else
 | 
			
		||||
        f.linked_keg.exist? && f.opt_prefix.exist?
 | 
			
		||||
@ -492,10 +490,9 @@ class FormulaInstaller
 | 
			
		||||
 | 
			
		||||
    c = Caveats.new(formula)
 | 
			
		||||
 | 
			
		||||
    unless c.empty?
 | 
			
		||||
      @show_summary_heading = true
 | 
			
		||||
      ohai "Caveats", c.caveats
 | 
			
		||||
    end
 | 
			
		||||
    return if c.empty?
 | 
			
		||||
    @show_summary_heading = true
 | 
			
		||||
    ohai "Caveats", c.caveats
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def finish
 | 
			
		||||
@ -706,13 +703,12 @@ class FormulaInstaller
 | 
			
		||||
      raise
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless link_overwrite_backup.empty?
 | 
			
		||||
      opoo "These files were overwritten during `brew link` step:"
 | 
			
		||||
      puts link_overwrite_backup.keys
 | 
			
		||||
      puts
 | 
			
		||||
      puts "They have been backed up in #{backup_dir}"
 | 
			
		||||
      @show_summary_heading = true
 | 
			
		||||
    end
 | 
			
		||||
    return if link_overwrite_backup.empty?
 | 
			
		||||
    opoo "These files were overwritten during `brew link` step:"
 | 
			
		||||
    puts link_overwrite_backup.keys
 | 
			
		||||
    puts
 | 
			
		||||
    puts "They have been backed up in #{backup_dir}"
 | 
			
		||||
    @show_summary_heading = true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install_plist
 | 
			
		||||
@ -804,10 +800,9 @@ class FormulaInstaller
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_check_output(output)
 | 
			
		||||
    if output
 | 
			
		||||
      opoo output
 | 
			
		||||
      @show_summary_heading = true
 | 
			
		||||
    end
 | 
			
		||||
    return unless output
 | 
			
		||||
    opoo output
 | 
			
		||||
    @show_summary_heading = true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_installed
 | 
			
		||||
@ -823,22 +818,20 @@ class FormulaInstaller
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def lock
 | 
			
		||||
    if (@@locked ||= []).empty?
 | 
			
		||||
      formula.recursive_dependencies.each do |dep|
 | 
			
		||||
        @@locked << dep.to_formula
 | 
			
		||||
      end unless ignore_deps?
 | 
			
		||||
      @@locked.unshift(formula)
 | 
			
		||||
      @@locked.uniq!
 | 
			
		||||
      @@locked.each(&:lock)
 | 
			
		||||
      @hold_locks = true
 | 
			
		||||
    end
 | 
			
		||||
    return unless (@@locked ||= []).empty?
 | 
			
		||||
    formula.recursive_dependencies.each do |dep|
 | 
			
		||||
      @@locked << dep.to_formula
 | 
			
		||||
    end unless ignore_deps?
 | 
			
		||||
    @@locked.unshift(formula)
 | 
			
		||||
    @@locked.uniq!
 | 
			
		||||
    @@locked.each(&:lock)
 | 
			
		||||
    @hold_locks = true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def unlock
 | 
			
		||||
    if hold_locks?
 | 
			
		||||
      @@locked.each(&:unlock)
 | 
			
		||||
      @@locked.clear
 | 
			
		||||
      @hold_locks = false
 | 
			
		||||
    end
 | 
			
		||||
    return unless hold_locks?
 | 
			
		||||
    @@locked.each(&:unlock)
 | 
			
		||||
    @@locked.clear
 | 
			
		||||
    @hold_locks = false
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -10,16 +10,14 @@ class FormulaLock
 | 
			
		||||
  def lock
 | 
			
		||||
    HOMEBREW_LOCK_DIR.mkpath
 | 
			
		||||
    @lockfile = get_or_create_lockfile
 | 
			
		||||
    unless @lockfile.flock(File::LOCK_EX | File::LOCK_NB)
 | 
			
		||||
      raise OperationInProgressError, @name
 | 
			
		||||
    end
 | 
			
		||||
    return if @lockfile.flock(File::LOCK_EX | File::LOCK_NB)
 | 
			
		||||
    raise OperationInProgressError, @name
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def unlock
 | 
			
		||||
    unless @lockfile.nil? || @lockfile.closed?
 | 
			
		||||
      @lockfile.flock(File::LOCK_UN)
 | 
			
		||||
      @lockfile.close
 | 
			
		||||
    end
 | 
			
		||||
    return if @lockfile.nil? || @lockfile.closed?
 | 
			
		||||
    @lockfile.flock(File::LOCK_UN)
 | 
			
		||||
    @lockfile.close
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def with_lock
 | 
			
		||||
 | 
			
		||||
@ -314,7 +314,9 @@ class Formulary
 | 
			
		||||
    possible_tap_formulae = tap_paths(ref)
 | 
			
		||||
    if possible_tap_formulae.size > 1
 | 
			
		||||
      raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae)
 | 
			
		||||
    elsif possible_tap_formulae.size == 1
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if possible_tap_formulae.size == 1
 | 
			
		||||
      path = possible_tap_formulae.first.resolved_path
 | 
			
		||||
      name = path.basename(".rb").to_s
 | 
			
		||||
      return FormulaLoader.new(name, path)
 | 
			
		||||
@ -336,7 +338,9 @@ class Formulary
 | 
			
		||||
 | 
			
		||||
    if possible_tap_newname_formulae.size > 1
 | 
			
		||||
      raise TapFormulaWithOldnameAmbiguityError.new(ref, possible_tap_newname_formulae)
 | 
			
		||||
    elsif !possible_tap_newname_formulae.empty?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless possible_tap_newname_formulae.empty?
 | 
			
		||||
      return TapLoader.new(possible_tap_newname_formulae.first)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -368,7 +372,9 @@ class Formulary
 | 
			
		||||
    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)
 | 
			
		||||
    elsif possible_pinned_tap_formulae.size == 1
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if possible_pinned_tap_formulae.size == 1
 | 
			
		||||
      selected_formula = factory(possible_pinned_tap_formulae.first, spec)
 | 
			
		||||
      if core_path(ref).file?
 | 
			
		||||
        opoo <<-EOS.undent
 | 
			
		||||
 | 
			
		||||
@ -394,10 +394,9 @@ class Keg
 | 
			
		||||
    opt_record.delete if opt_record.symlink? || opt_record.exist?
 | 
			
		||||
    make_relative_symlink(opt_record, path, mode)
 | 
			
		||||
 | 
			
		||||
    if oldname_opt_record
 | 
			
		||||
      oldname_opt_record.delete
 | 
			
		||||
      make_relative_symlink(oldname_opt_record, path, mode)
 | 
			
		||||
    end
 | 
			
		||||
    return unless oldname_opt_record
 | 
			
		||||
    oldname_opt_record.delete
 | 
			
		||||
    make_relative_symlink(oldname_opt_record, path, mode)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def delete_pyc_files!
 | 
			
		||||
@ -423,18 +422,19 @@ class Keg
 | 
			
		||||
      return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if stat.directory?
 | 
			
		||||
      begin
 | 
			
		||||
        keg = Keg.for(src)
 | 
			
		||||
      rescue NotAKegError
 | 
			
		||||
        puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if ARGV.verbose?
 | 
			
		||||
        return
 | 
			
		||||
    return unless stat.directory?
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
      dst.unlink unless mode.dry_run
 | 
			
		||||
      keg.link_dir(src, mode) { :mkpath }
 | 
			
		||||
      return true
 | 
			
		||||
      return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    dst.unlink unless mode.dry_run
 | 
			
		||||
    keg.link_dir(src, mode) { :mkpath }
 | 
			
		||||
    true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def make_relative_symlink(dst, src, mode)
 | 
			
		||||
@ -462,9 +462,8 @@ class Keg
 | 
			
		||||
    dst.delete if mode.overwrite && (dst.exist? || dst.symlink?)
 | 
			
		||||
    dst.make_relative_symlink(src)
 | 
			
		||||
  rescue Errno::EEXIST => e
 | 
			
		||||
    if dst.exist?
 | 
			
		||||
      raise ConflictError.new(self, src.relative_path_from(path), dst, e)
 | 
			
		||||
    elsif dst.symlink?
 | 
			
		||||
    raise ConflictError.new(self, src.relative_path_from(path), dst, e) if dst.exist?
 | 
			
		||||
    if dst.symlink?
 | 
			
		||||
      dst.unlink
 | 
			
		||||
      retry
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -182,22 +182,21 @@ class Migrator
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def repin
 | 
			
		||||
    if pinned?
 | 
			
		||||
      # old_pin_record is a relative symlink and when we try to to read it
 | 
			
		||||
      # from <dir> we actually try to find file
 | 
			
		||||
      # <dir>/../<...>/../Cellar/name/version.
 | 
			
		||||
      # To repin formula we need to update the link thus that it points to
 | 
			
		||||
      # the right directory.
 | 
			
		||||
      # NOTE: old_pin_record.realpath.sub(oldname, newname) is unacceptable
 | 
			
		||||
      # here, because it resolves every symlink for old_pin_record and then
 | 
			
		||||
      # substitutes oldname with newname. It breaks things like
 | 
			
		||||
      # Pathname#make_relative_symlink, where Pathname#relative_path_from
 | 
			
		||||
      # is used to find relative path from source to destination parent and
 | 
			
		||||
      # it assumes no symlinks.
 | 
			
		||||
      src_oldname = old_pin_record.dirname.join(old_pin_link_record).expand_path
 | 
			
		||||
      new_pin_record.make_relative_symlink(src_oldname.sub(oldname, newname))
 | 
			
		||||
      old_pin_record.delete
 | 
			
		||||
    end
 | 
			
		||||
    return unless pinned?
 | 
			
		||||
    # old_pin_record is a relative symlink and when we try to to read it
 | 
			
		||||
    # from <dir> we actually try to find file
 | 
			
		||||
    # <dir>/../<...>/../Cellar/name/version.
 | 
			
		||||
    # To repin formula we need to update the link thus that it points to
 | 
			
		||||
    # the right directory.
 | 
			
		||||
    # NOTE: old_pin_record.realpath.sub(oldname, newname) is unacceptable
 | 
			
		||||
    # here, because it resolves every symlink for old_pin_record and then
 | 
			
		||||
    # substitutes oldname with newname. It breaks things like
 | 
			
		||||
    # Pathname#make_relative_symlink, where Pathname#relative_path_from
 | 
			
		||||
    # is used to find relative path from source to destination parent and
 | 
			
		||||
    # it assumes no symlinks.
 | 
			
		||||
    src_oldname = old_pin_record.dirname.join(old_pin_link_record).expand_path
 | 
			
		||||
    new_pin_record.make_relative_symlink(src_oldname.sub(oldname, newname))
 | 
			
		||||
    old_pin_record.delete
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def unlink_oldname
 | 
			
		||||
@ -254,10 +253,9 @@ class Migrator
 | 
			
		||||
 | 
			
		||||
  # Link keg to opt if it was linked before migrating.
 | 
			
		||||
  def link_oldname_opt
 | 
			
		||||
    if old_opt_record
 | 
			
		||||
      old_opt_record.delete if old_opt_record.symlink?
 | 
			
		||||
      old_opt_record.make_relative_symlink(new_linked_keg_record)
 | 
			
		||||
    end
 | 
			
		||||
    return unless old_opt_record
 | 
			
		||||
    old_opt_record.delete if old_opt_record.symlink?
 | 
			
		||||
    old_opt_record.make_relative_symlink(new_linked_keg_record)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # After migtaion every INSTALL_RECEIPT.json has wrong path to the formula
 | 
			
		||||
@ -316,23 +314,22 @@ class Migrator
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless old_linked_keg.nil?
 | 
			
		||||
      # The keg used to be linked and when we backup everything we restore
 | 
			
		||||
      # Cellar/oldname, the target also gets restored, so we are able to
 | 
			
		||||
      # create a keg using its old path
 | 
			
		||||
      if old_linked_keg_record
 | 
			
		||||
        begin
 | 
			
		||||
          old_linked_keg.link
 | 
			
		||||
        rescue Keg::LinkError
 | 
			
		||||
          old_linked_keg.unlink
 | 
			
		||||
          raise
 | 
			
		||||
        rescue Keg::AlreadyLinkedError
 | 
			
		||||
          old_linked_keg.unlink
 | 
			
		||||
          retry
 | 
			
		||||
        end
 | 
			
		||||
      else
 | 
			
		||||
        old_linked_keg.optlink
 | 
			
		||||
    return if old_linked_keg.nil?
 | 
			
		||||
    # The keg used to be linked and when we backup everything we restore
 | 
			
		||||
    # Cellar/oldname, the target also gets restored, so we are able to
 | 
			
		||||
    # create a keg using its old path
 | 
			
		||||
    if old_linked_keg_record
 | 
			
		||||
      begin
 | 
			
		||||
        old_linked_keg.link
 | 
			
		||||
      rescue Keg::LinkError
 | 
			
		||||
        old_linked_keg.unlink
 | 
			
		||||
        raise
 | 
			
		||||
      rescue Keg::AlreadyLinkedError
 | 
			
		||||
        old_linked_keg.unlink
 | 
			
		||||
        retry
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      old_linked_keg.optlink
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -18,12 +18,10 @@ module OS
 | 
			
		||||
        when "10.11" then "8.0"
 | 
			
		||||
        when "10.12" then "8.0"
 | 
			
		||||
        else
 | 
			
		||||
          raise "macOS '#{MacOS.version}' is invalid" unless OS::Mac.prerelease?
 | 
			
		||||
 | 
			
		||||
          # Default to newest known version of Xcode for unreleased macOS versions.
 | 
			
		||||
          if OS::Mac.prerelease?
 | 
			
		||||
            "8.0"
 | 
			
		||||
          else
 | 
			
		||||
            raise "macOS '#{MacOS.version}' is invalid"
 | 
			
		||||
          end
 | 
			
		||||
          "8.0"
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -130,14 +130,13 @@ class ExternalPatch
 | 
			
		||||
      patch_dir = Pathname.pwd
 | 
			
		||||
      if patch_files.empty?
 | 
			
		||||
        children = patch_dir.children
 | 
			
		||||
        if children.length == 1 && children.first.file?
 | 
			
		||||
          patch_files << children.first.basename
 | 
			
		||||
        else
 | 
			
		||||
        if children.length != 1 || !children.first.file?
 | 
			
		||||
          raise MissingApplyError, <<-EOS.undent
 | 
			
		||||
            There should be exactly one patch file in the staging directory unless
 | 
			
		||||
            the "apply" method was used one or more times in the patch-do block.
 | 
			
		||||
          EOS
 | 
			
		||||
        end
 | 
			
		||||
        patch_files << children.first.basename
 | 
			
		||||
      end
 | 
			
		||||
      dir.cd do
 | 
			
		||||
        patch_files.each do |patch_file|
 | 
			
		||||
 | 
			
		||||
@ -83,12 +83,11 @@ class Requirement
 | 
			
		||||
    # PATH.
 | 
			
		||||
    # This is undocumented magic and it should be removed, but we need to add
 | 
			
		||||
    # a way to declare path-based requirements that work with superenv first.
 | 
			
		||||
    if @satisfied_result.is_a?(Pathname)
 | 
			
		||||
      parent = @satisfied_result.parent
 | 
			
		||||
      unless ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s)
 | 
			
		||||
        ENV.append_path("PATH", parent)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    return unless @satisfied_result.is_a?(Pathname)
 | 
			
		||||
    parent = @satisfied_result.parent
 | 
			
		||||
 | 
			
		||||
    return if ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s)
 | 
			
		||||
    ENV.append_path("PATH", parent)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def env
 | 
			
		||||
@ -199,11 +198,8 @@ class Requirement
 | 
			
		||||
 | 
			
		||||
      formulae.each do |f|
 | 
			
		||||
        f.requirements.each do |req|
 | 
			
		||||
          if prune?(f, req, &block)
 | 
			
		||||
            next
 | 
			
		||||
          else
 | 
			
		||||
            reqs << req
 | 
			
		||||
          end
 | 
			
		||||
          next if prune?(f, req, &block)
 | 
			
		||||
          reqs << req
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -130,9 +130,8 @@ class Tap
 | 
			
		||||
  # The issues URL of this {Tap}.
 | 
			
		||||
  # e.g. `https://github.com/user/homebrew-repo/issues`
 | 
			
		||||
  def issues_url
 | 
			
		||||
    if official? || !custom_remote?
 | 
			
		||||
      "https://github.com/#{user}/homebrew-#{repo}/issues"
 | 
			
		||||
    end
 | 
			
		||||
    return unless official? || !custom_remote?
 | 
			
		||||
    "https://github.com/#{user}/homebrew-#{repo}/issues"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def to_s
 | 
			
		||||
@ -236,15 +235,16 @@ class Tap
 | 
			
		||||
    puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{path.abv})" unless quiet
 | 
			
		||||
    Descriptions.cache_formulae(formula_names)
 | 
			
		||||
 | 
			
		||||
    if !options[:clone_target] && private? && !quiet
 | 
			
		||||
      puts <<-EOS.undent
 | 
			
		||||
        It looks like you tapped a private repository. To avoid entering your
 | 
			
		||||
        credentials each time you update, you can use git HTTP credential
 | 
			
		||||
        caching or issue the following command:
 | 
			
		||||
          cd #{path}
 | 
			
		||||
          git remote set-url origin git@github.com:#{user}/homebrew-#{repo}.git
 | 
			
		||||
      EOS
 | 
			
		||||
    end
 | 
			
		||||
    return if options[:clone_target]
 | 
			
		||||
    return unless private?
 | 
			
		||||
    return if quiet
 | 
			
		||||
    puts <<-EOS.undent
 | 
			
		||||
      It looks like you tapped a private repository. To avoid entering your
 | 
			
		||||
      credentials each time you update, you can use git HTTP credential
 | 
			
		||||
      caching or issue the following command:
 | 
			
		||||
        cd #{path}
 | 
			
		||||
        git remote set-url origin git@github.com:#{user}/homebrew-#{repo}.git
 | 
			
		||||
    EOS
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def link_manpages
 | 
			
		||||
 | 
			
		||||
@ -45,9 +45,8 @@ class TestbotStepTests < Homebrew::TestCase
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def teardown
 | 
			
		||||
    unless passed?
 | 
			
		||||
      raise "INFO: Previous test failed with ENV['TRAVIS'] = #{ENV["TRAVIS"].inspect}"
 | 
			
		||||
    end
 | 
			
		||||
    return if passed?
 | 
			
		||||
    raise "INFO: Previous test failed with ENV['TRAVIS'] = #{ENV["TRAVIS"].inspect}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def stub_test_instance
 | 
			
		||||
 | 
			
		||||
@ -39,9 +39,8 @@ class IntegrationCommandTests < Homebrew::TestCase
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def needs_test_cmd_taps
 | 
			
		||||
    unless ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
 | 
			
		||||
      skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set"
 | 
			
		||||
    end
 | 
			
		||||
    return if ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
 | 
			
		||||
    skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def needs_macos
 | 
			
		||||
 | 
			
		||||
@ -57,9 +57,8 @@ module Homebrew
 | 
			
		||||
      super
 | 
			
		||||
      files_after_test = []
 | 
			
		||||
      Find.find(TEST_TMPDIR) { |f| files_after_test << f.sub(TEST_TMPDIR, "") }
 | 
			
		||||
      if @__files_before_test != files_after_test
 | 
			
		||||
        @@log.puts location, diff(@__files_before_test, files_after_test)
 | 
			
		||||
      end
 | 
			
		||||
      return if @__files_before_test == files_after_test
 | 
			
		||||
      @@log.puts location, diff(@__files_before_test, files_after_test)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -218,13 +218,9 @@ def interactive_shell(f = nil)
 | 
			
		||||
 | 
			
		||||
  Process.wait fork { exec ENV["SHELL"] }
 | 
			
		||||
 | 
			
		||||
  if $?.success?
 | 
			
		||||
    return
 | 
			
		||||
  elsif $?.exited?
 | 
			
		||||
    raise "Aborted due to non-zero exit status (#{$?.exitstatus})"
 | 
			
		||||
  else
 | 
			
		||||
    raise $?.inspect
 | 
			
		||||
  end
 | 
			
		||||
  return if $?.success?
 | 
			
		||||
  raise "Aborted due to non-zero exit status (#{$?.exitstatus})" if $?.exited?
 | 
			
		||||
  raise $?.inspect
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
module Homebrew
 | 
			
		||||
@ -325,13 +321,12 @@ module Homebrew
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if $times.nil?
 | 
			
		||||
      $times = {}
 | 
			
		||||
      at_exit do
 | 
			
		||||
        col_width = [$times.keys.map(&:size).max + 2, 15].max
 | 
			
		||||
        $times.sort_by { |_k, v| v }.each do |method, time|
 | 
			
		||||
          puts format("%-*s %0.4f sec", col_width, "#{method}:", time)
 | 
			
		||||
        end
 | 
			
		||||
    return unless $times.nil?
 | 
			
		||||
    $times = {}
 | 
			
		||||
    at_exit do
 | 
			
		||||
      col_width = [$times.keys.map(&:size).max + 2, 15].max
 | 
			
		||||
      $times.sort_by { |_k, v| v }.each do |method, time|
 | 
			
		||||
        puts format("%-*s %0.4f sec", col_width, "#{method}:", time)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
@ -608,14 +603,14 @@ def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
 | 
			
		||||
    dst_dir.parent.mkpath
 | 
			
		||||
    dst.make_relative_symlink(src)
 | 
			
		||||
  end
 | 
			
		||||
  unless conflicts.empty?
 | 
			
		||||
    onoe <<-EOS.undent
 | 
			
		||||
      Could not link:
 | 
			
		||||
      #{conflicts.join("\n")}
 | 
			
		||||
 | 
			
		||||
      Please delete these paths and run `#{command}`.
 | 
			
		||||
    EOS
 | 
			
		||||
  end
 | 
			
		||||
  return if conflicts.empty?
 | 
			
		||||
  onoe <<-EOS.undent
 | 
			
		||||
    Could not link:
 | 
			
		||||
    #{conflicts.join("\n")}
 | 
			
		||||
 | 
			
		||||
    Please delete these paths and run `#{command}`.
 | 
			
		||||
  EOS
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
def link_path_manpages(path, command)
 | 
			
		||||
 | 
			
		||||
@ -14,11 +14,8 @@ module Utils
 | 
			
		||||
  def self.popen(args, mode)
 | 
			
		||||
    IO.popen("-", mode) do |pipe|
 | 
			
		||||
      if pipe
 | 
			
		||||
        if block_given?
 | 
			
		||||
          yield pipe
 | 
			
		||||
        else
 | 
			
		||||
          return pipe.read
 | 
			
		||||
        end
 | 
			
		||||
        return pipe.read unless block_given?
 | 
			
		||||
        yield pipe
 | 
			
		||||
      else
 | 
			
		||||
        $stderr.reopen("/dev/null", "w")
 | 
			
		||||
        exec(*args)
 | 
			
		||||
 | 
			
		||||
@ -192,11 +192,10 @@ class Version
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def initialize(val)
 | 
			
		||||
    if val.respond_to?(:to_str)
 | 
			
		||||
      @version = val.to_str
 | 
			
		||||
    else
 | 
			
		||||
    unless val.respond_to?(:to_str)
 | 
			
		||||
      raise TypeError, "Version value must be a string; got a #{val.class} (#{val})"
 | 
			
		||||
    end
 | 
			
		||||
    @version = val.to_str
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def detected_from_url?
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user