Skip to content

Instantly share code, notes, and snippets.

@lenary
Created January 16, 2010 12:13
Show Gist options
  • Save lenary/278801 to your computer and use it in GitHub Desktop.
Save lenary/278801 to your computer and use it in GitHub Desktop.
Rails 3 Updater - requires vendored rails and rvm
#!/usr/bin/env ruby
require 'fileutils'
# switches to vendor/rails and pulls rails, and shows you the commit
pull = ''
FileUtils.cd('vendor/rails', :verbose => true) do |foo|
puts "Pulling Rails"
pull = %x{git pull origin master 2> /dev/null}
puts pull
git_commit = ''
File.open('.git/refs/heads/master', 'r') do |file|
git_commit = file.read
end
puts "Rails Commit: #{git_commit}"
end
# Tells you the ruby you're using
version = ""
if %x{ruby -v} =~ /\w ([\d\.]+) (.*)/i
version = $1
puts "Using Ruby: #{version}"
end
# if pull is not up to date, bundles the gems again.
unless pull =~ Regexp.new("Already up-to-date")
FileUtils.rm_rf('vendor/gems', :verbose => true)
puts %x{rvm use 1.9.1}
puts %x{gem bundle}
puts %x{rvm use 1.8.7}
puts %x{gem bundle}
puts %x{rvm use #{version}}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment