Created
May 26, 2009 13:17
-
-
Save webmat/118061 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
# Our deployment tags are s or p followed by YYmmdd-HHMMSS | |
namespace :deploy do | |
namespace :pending do | |
desc "Show the list of new migrations since the last deployments to staging and production" | |
task :migrations do | |
tags = run_locally("git tag").split | |
staging = tags.grep(/\As\d{6}-\d{6}\Z/).sort.last | |
production = tags.grep(/\Ap\d{6}-\d{6}\Z/).sort.last | |
%w(staging production).each do |stage| | |
puts '', stage | |
result = run_locally %(git diff --numstat #{ eval(stage) }..master | grep "db\/migrate") | |
puts(result.strip == '' ? '(none)' : result.gsub(/\d*\t\d*\t/, '') ) | |
end | |
end | |
end | |
end | |
=begin | |
Example output: | |
$ cap deploy:pending:migrations | |
triggering start callbacks for `deploy:pending:migrations' | |
* executing `multistage:ensure' | |
*** Defaulting to `staging' | |
* executing `staging' | |
* executing `deploy:pending:migrations' | |
executing locally: "git tag" | |
staging | |
executing locally: "git diff --numstat s090525-165241..master | grep \"db/migrate\"" | |
(none) | |
production | |
executing locally: "git diff --numstat p090522-090244..master | grep \"db/migrate\"" | |
db/migrate/20090511155004_create_audits.rb | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment