Select Git revision
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