Skip to content
Snippets Groups Projects
Select Git revision
  • ad8556cceaff65b1b613d1201951680c392cb481
  • master default protected
  • dependabot/bundler/Library/Homebrew/parser-3.0.3.1
  • dependabot/bundler/Library/Homebrew/tapioca-0.5.5
  • dependabot/bundler/Library/Homebrew/simplecov-cobertura-2.0.0
  • dependabot/bundler/Library/Homebrew/bootsnap-1.9.3
  • dependabot/bundler/Library/Homebrew/sorbet-0.5.9368
  • dependabot/bundler/Library/Homebrew/sorbet-0.5.9363
  • dependabot/bundler/docs/github-pages-222
  • dependabot/bundler/Library/Homebrew/sorbet-0.5.9358
  • dependabot/bundler/Library/Homebrew/mime-types-data-3.2021.1115
  • dependabot/bundler/Library/Homebrew/rbi-0.0.7
  • dependabot/bundler/Library/Homebrew/mime-types-3.4.1
  • dependabot/bundler/Library/Homebrew/sorbet-0.5.9327
  • dependabot/bundler/Library/Homebrew/rubocop-1.23.0
  • dependabot/bundler/Library/Homebrew/sorbet-0.5.9319
  • dependabot/bundler/docs/http_parser.rb-0.8.0
  • dependabot/bundler/docs/em-websocket-0.5.3
  • spdx-update
  • gogetinstall
  • dependabot/bundler/Library/Homebrew/mechanize-2.8.3
  • 3.3.6
  • 3.3.5
  • 3.3.4
  • 3.3.3
  • 3.3.2
  • 3.3.1
  • 3.3.0
  • 3.2.17
  • 3.2.16
  • 3.2.15
  • 3.2.14
  • 3.2.13
  • 3.2.12
  • 3.2.11
  • 3.2.10
  • 3.2.9
  • 3.2.8
  • 3.2.7
  • 3.2.6
  • 3.2.5
41 results

doctor.rb

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    doctor.rb 36.25 KiB
    require "cmd/missing"
    require "formula"
    require "keg"
    require "version"
    
    class Volumes
      def initialize
        @volumes = get_mounts
      end
    
      def which path
        vols = get_mounts path
    
        # no volume found
        if vols.empty?
          return -1
        end
    
        vol_index = @volumes.index(vols[0])
        # volume not found in volume list
        if vol_index.nil?
          return -1
        end
        return vol_index
      end
    
      def get_mounts path=nil
        vols = []
        # get the volume of path, if path is nil returns all volumes
    
        args = %w[/bin/df -P]
        args << path if path
    
        Utils.popen_read(*args) do |io|
          io.each_line do |line|
            case line.chomp
              # regex matches: /dev/disk0s2   489562928 440803616  48247312    91%    /
            when /^.+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[0-9]{1,3}%\s+(.+)/
              vols << $1
            end
          end
        end
        return vols
      end
    end
    
    
    class Checks
    
    ############# HELPERS
      # Finds files in HOMEBREW_PREFIX *and* /usr/local.
      # Specify paths relative to a prefix eg. "include/foo.h".
      # Sets @found for your convenience.
      def find_relative_paths *relative_paths
        @found = %W[#{HOMEBREW_PREFIX} /usr/local].uniq.inject([]) do |found, prefix|
          found + relative_paths.map{|f| File.join(prefix, f) }.select{|f| File.exist? f }
        end
      end
    
      def inject_file_list(list, str)
        list.inject(str) { |s, f| s << "    #{f}\n" }
      end
    
      # Git will always be on PATH because of the wrapper script in
      # Library/Contributions/cmd, so we check if there is a *real*
      # git here to avoid multiple warnings.
      def git?
        return @git if instance_variable_defined?(:@git)
        @git = system "git --version >/dev/null 2>&1"
      end