aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2009-12-15 12:47:12 +0000
committerMax Howell2009-12-17 13:45:08 +0000
commit64cdda87e07a3a79e2e6cc97a01f6ca17650760e (patch)
tree8a5dd27cea4390ff8cad0822e27447ef7b3fc5d6 /Library
parente50d68ec8d01d941427e8a8f6b69d4bac792f9b2 (diff)
downloadbrew-64cdda87e07a3a79e2e6cc97a01f6ca17650760e.tar.bz2
Be more quiet about checkouts unless ARGV.verbose?
Fixes Homebrew/homebrew#204
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb35
1 files changed, 26 insertions, 9 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 8cbb4cc5e..e2a50b1d3 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -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