Skip to content

Instantly share code, notes, and snippets.

@webmat
Created May 26, 2009 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmat/118061 to your computer and use it in GitHub Desktop.
Save webmat/118061 to your computer and use it in GitHub Desktop.
# 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