Be more quiet about checkouts unless ARGV.verbose?
Fixes Homebrew/homebrew#204
This commit is contained in:
parent
e50d68ec8d
commit
64cdda87e0
@ -30,6 +30,26 @@ class AbstractDownloadStrategy
|
|||||||
end
|
end
|
||||||
@unique_token="#{name}-#{version}" unless name.to_s.empty? or name == '__UNKNOWN__'
|
@unique_token="#{name}-#{version}" unless name.to_s.empty? or name == '__UNKNOWN__'
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
class CurlDownloadStrategy <AbstractDownloadStrategy
|
class CurlDownloadStrategy <AbstractDownloadStrategy
|
||||||
@ -59,7 +79,7 @@ class CurlDownloadStrategy <AbstractDownloadStrategy
|
|||||||
# get the first four bytes
|
# get the first four bytes
|
||||||
case f.read(4)
|
case f.read(4)
|
||||||
when /^PK\003\004/ # .zip archive
|
when /^PK\003\004/ # .zip archive
|
||||||
safe_system '/usr/bin/unzip', '-qq', @dl
|
quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @dl
|
||||||
chdir
|
chdir
|
||||||
when /^\037\213/, /^BZh/ # gzip/bz2 compressed
|
when /^\037\213/, /^BZh/ # gzip/bz2 compressed
|
||||||
# TODO check if it's really a tar archive
|
# TODO check if it's really a tar archive
|
||||||
@ -113,9 +133,7 @@ class SubversionDownloadStrategy <AbstractDownloadStrategy
|
|||||||
ohai "Checking out #{@url}"
|
ohai "Checking out #{@url}"
|
||||||
@co=HOMEBREW_CACHE+@unique_token
|
@co=HOMEBREW_CACHE+@unique_token
|
||||||
unless @co.exist?
|
unless @co.exist?
|
||||||
args = [svn, 'checkout', @url, @co]
|
quiet_safe_system svn, 'checkout', @url, @co
|
||||||
args << '-q' unless ARGV.verbose?
|
|
||||||
safe_system *args
|
|
||||||
else
|
else
|
||||||
# TODO svn up?
|
# TODO svn up?
|
||||||
puts "Repository already checked out"
|
puts "Repository already checked out"
|
||||||
@ -126,8 +144,7 @@ class SubversionDownloadStrategy <AbstractDownloadStrategy
|
|||||||
# Force the export, since the target directory will already exist
|
# Force the export, since the target directory will already exist
|
||||||
args = [svn, 'export', '--force', @co, Dir.pwd]
|
args = [svn, 'export', '--force', @co, Dir.pwd]
|
||||||
args << '-r' << @ref if @spec == :revision and @ref
|
args << '-r' << @ref if @spec == :revision and @ref
|
||||||
args << '-q' unless ARGV.verbose?
|
quiet_safe_system *args
|
||||||
safe_system *args
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Override this method in a DownloadStrategy to force the use of a non-
|
# Override this method in a DownloadStrategy to force the use of a non-
|
||||||
@ -143,7 +160,7 @@ class GitDownloadStrategy <AbstractDownloadStrategy
|
|||||||
ohai "Cloning #{@url}"
|
ohai "Cloning #{@url}"
|
||||||
@clone=HOMEBREW_CACHE+@unique_token
|
@clone=HOMEBREW_CACHE+@unique_token
|
||||||
unless @clone.exist?
|
unless @clone.exist?
|
||||||
safe_system 'git', 'clone', @url, @clone
|
quiet_safe_system 'git', 'clone', @url, @clone
|
||||||
else
|
else
|
||||||
# TODO git pull?
|
# TODO git pull?
|
||||||
puts "Repository already cloned to #{@clone}"
|
puts "Repository already cloned to #{@clone}"
|
||||||
@ -157,9 +174,9 @@ class GitDownloadStrategy <AbstractDownloadStrategy
|
|||||||
ohai "Checking out #{@spec} #{@ref}"
|
ohai "Checking out #{@spec} #{@ref}"
|
||||||
case @spec
|
case @spec
|
||||||
when :branch
|
when :branch
|
||||||
nostdout { safe_system 'git', 'checkout', "origin/#{@ref}" }
|
nostdout { quiet_safe_system 'git', 'checkout', "origin/#{@ref}" }
|
||||||
when :tag
|
when :tag
|
||||||
nostdout { safe_system 'git', 'checkout', @ref }
|
nostdout { quiet_safe_system 'git', 'checkout', @ref }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
|
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user