-
-
Save rrichards/279275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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