Skip to content

Instantly share code, notes, and snippets.

@AlekSi
Created August 21, 2011 15:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlekSi/1160734 to your computer and use it in GitHub Desktop.
Save AlekSi/1160734 to your computer and use it in GitHub Desktop.
Update all gems, packages, fetch all code, etc.
#! /usr/bin/env ruby
STDOUT.sync = true
STDERR.sync = true
def run(cmd, *ok_statuses)
puts "\n=========> #{cmd}"
system(cmd)
unless ([0] + ok_statuses).include?($?)
puts "Exit status: #{$?}"
exit $?
end
end
run('rvm get latest')
run('rvm all do gem update --system', 256)
run('rvm all do gem update')
# packages = `pip freeze`.lines.map { |line| line.split('==')[0] }
# run("pip install --upgrade #{packages.join(' ')}")
run('brew update')
home = File.expand_path('~')
%w(Code Documents Sites).each do |root|
dir = "#{home}/#{root}/"
Dir["#{dir}*"].each do |path|
if File.directory?(path) && File.directory?("#{path}/.git")
run("cd #{path} && git fetch --all --prune && git submodule update --init && git gc --auto")
if File.directory?("#{path}/.git/hgcheckout")
run("cd #{path} && git hg fetch", 255)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment