Be more quiet about checkouts unless ARGV.verbose?

Fixes Homebrew/homebrew#204
This commit is contained in:
Max Howell 2009-12-15 12:47:12 +00:00
parent e50d68ec8d
commit 64cdda87e0

View File

@ -30,6 +30,26 @@ class AbstractDownloadStrategy
end
@unique_token="#{name}-#{version}" unless name.to_s.empty? or name == '__UNKNOWN__'
end
def expand_safe_system_args args
args.each_with_index do |arg, ii|
if arg.is_a? Hash
unless ARGV.verbose?
args[ii] = arg[:quiet_flag]
else
args.delete_at ii
end
return args
end
end
# 2 as default because commands are eg. svn up, git pull
args.insert(2, '-q') unless ARGV.verbose?
return args
end
def quiet_safe_system *args
safe_system *expand_safe_system_args(args)
end
end
class CurlDownloadStrategy <AbstractDownloadStrategy
@ -59,7 +79,7 @@ class CurlDownloadStrategy <AbstractDownloadStrategy
# get the first four bytes
case f.read(4)
when /^PK\003\004/ # .zip archive
safe_system '/usr/bin/unzip', '-qq', @dl
quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @dl
chdir
when /^\037\213/, /^BZh/ # gzip/bz2 compressed
# TODO check if it's really a tar archive
@ -113,9 +133,7 @@ class SubversionDownloadStrategy <AbstractDownloadStrategy
ohai "Checking out #{@url}"
@co=HOMEBREW_CACHE+@unique_token
unless @co.exist?
args = [svn, 'checkout', @url, @co]
args << '-q' unless ARGV.verbose?
safe_system *args
quiet_safe_system svn, 'checkout', @url, @co
else
# TODO svn up?
puts "Repository already checked out"
@ -126,8 +144,7 @@ class SubversionDownloadStrategy <AbstractDownloadStrategy
# Force the export, since the target directory will already exist
args = [svn, 'export', '--force', @co, Dir.pwd]
args << '-r' << @ref if @spec == :revision and @ref
args << '-q' unless ARGV.verbose?
safe_system *args
quiet_safe_system *args
end
# Override this method in a DownloadStrategy to force the use of a non-
@ -143,7 +160,7 @@ class GitDownloadStrategy <AbstractDownloadStrategy
ohai "Cloning #{@url}"
@clone=HOMEBREW_CACHE+@unique_token
unless @clone.exist?
safe_system 'git', 'clone', @url, @clone
quiet_safe_system 'git', 'clone', @url, @clone
else
# TODO git pull?
puts "Repository already cloned to #{@clone}"
@ -157,9 +174,9 @@ class GitDownloadStrategy <AbstractDownloadStrategy
ohai "Checking out #{@spec} #{@ref}"
case @spec
when :branch
nostdout { safe_system 'git', 'checkout', "origin/#{@ref}" }
nostdout { quiet_safe_system 'git', 'checkout', "origin/#{@ref}" }
when :tag
nostdout { safe_system 'git', 'checkout', @ref }
nostdout { quiet_safe_system 'git', 'checkout', @ref }
end
end
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export