Made the output of updating a bit nicer and log more if --verbose.

This commit is contained in:
Eloy Duran 2009-09-11 20:09:39 +02:00
parent bb03db8e6c
commit 3b8f3ad409
2 changed files with 11 additions and 4 deletions

View File

@ -27,7 +27,7 @@ class RefreshBrew
end end
def current_revision def current_revision
in_prefix { `#{REVISION_COMMAND}`.strip } in_prefix { execute(REVISION_COMMAND).strip }
end end
private private
@ -36,11 +36,17 @@ class RefreshBrew
Dir.chdir(HOMEBREW_PREFIX) { yield } Dir.chdir(HOMEBREW_PREFIX) { yield }
end end
def execute(cmd)
out = `#{cmd}`
ohai "#{cmd}: #{out}" if ARGV.verbose?
out
end
def git_checkout_masterbrew! def git_checkout_masterbrew!
in_prefix { `#{CHECKOUT_COMMAND}` } in_prefix { execute CHECKOUT_COMMAND }
end end
def git_pull! def git_pull!
in_prefix { `#{UPDATE_COMMAND}` } in_prefix { execute UPDATE_COMMAND }
end end
end end

View File

@ -113,10 +113,11 @@ begin
when 'up', 'update' when 'up', 'update'
require 'refresh_brew' require 'refresh_brew'
updater = RefreshBrew.new updater = RefreshBrew.new
old_revision = updater.current_revision
unless updater.update_from_masterbrew! unless updater.update_from_masterbrew!
ohai "Already up-to-date." ohai "Already up-to-date."
else else
ohai "Updated Homebrew to: #{updater.current_revision}" ohai "Updated Homebrew from #{old_revision} to #{updater.current_revision}."
if updater.pending_formulae_changes? if updater.pending_formulae_changes?
ohai "The following formulae were updated: #{updater.updated_formulae.join(', ')}" ohai "The following formulae were updated: #{updater.updated_formulae.join(', ')}"
else else