From 7368b3b7fc9274b668805d3387b86462a466ed33 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 11 Jun 2012 11:07:10 -0400 Subject: [PATCH] add migrate if chanfged and fix tail --- lib/cap-pack/recipes/rails/migrate_if_changed.rb | 9 +++++++++ lib/cap-pack/recipes/tail.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 lib/cap-pack/recipes/rails/migrate_if_changed.rb diff --git a/lib/cap-pack/recipes/rails/migrate_if_changed.rb b/lib/cap-pack/recipes/rails/migrate_if_changed.rb new file mode 100644 index 0000000..6f4e3fb --- /dev/null +++ b/lib/cap-pack/recipes/rails/migrate_if_changed.rb @@ -0,0 +1,9 @@ +namespace :rails do + desc 'Migrate the database if db/schema.rb has changed since the last revision' + task :migrate_if_changed do + if !(result = %x{git log #{current_revision}..#{revision} db/schema.rb}.strip).empty? + top.deploy.migrate + end + end +end + diff --git a/lib/cap-pack/recipes/tail.rb b/lib/cap-pack/recipes/tail.rb index 4191c83..aface01 100644 --- a/lib/cap-pack/recipes/tail.rb +++ b/lib/cap-pack/recipes/tail.rb @@ -1,7 +1,7 @@ desc "Tail all or a single remote file" task :tail do pattern = ENV["LOGFILE_PATTERN"] || "*.log" - run "tail -f #{shared_path}/log/#{ENV["LOGFILE_PATTERN"]}" do |channel, stream, data| + run "tail -f #{shared_path}/log/#{pattern}" do |channel, stream, data| puts "#{data}" break if stream == :err end