Permalink
Browse files

Don't try to skip asset precompilation if previous_release is nil.

If previous_release is nil it most likely means that this is your first deploy.
  • Loading branch information...
1 parent 2ee5914 commit 4ee9d459c18703844d3fefc53c98690fb7f6d90e @jeroenj jeroenj committed Apr 19, 2012
Showing with 11 additions and 6 deletions.
  1. +11 −6 lib/openminds_deploy/rails3.rb
@@ -24,14 +24,19 @@
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => {:no_release => true} do
- old_rev = capture("cd #{previous_release} && git log --pretty=format:'%H' -n 1 | cat").strip
- new_rev = capture("cd #{latest_release} && git log --pretty=format:'%H' -n 1 | cat").strip
- assets_changed = capture("cd #{latest_release} && git diff #{old_rev} #{new_rev} --name-only | cat").include?('asset')
- gemfile_changed = capture("cd #{latest_release} && git diff #{old_rev} #{new_rev} --name-only | cat").include?('Gemfile.lock')
- if assets_changed || (gemfile_changed && Capistrano::CLI.ui.ask("Gemfile changed. Enter 'yes' to precomple assets?") == 'yes')
+ changed = if previous_release.nil?
+ # Propably first deploy, so precompile them anyway.
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile"
else
- logger.info 'Skipping asset precompilation because there were no asset changes.'
+ old_rev = capture("cd #{previous_release} && git log --pretty=format:'%H' -n 1 | cat").strip
+ new_rev = capture("cd #{latest_release} && git log --pretty=format:'%H' -n 1 | cat").strip
+ assets_changed = capture("cd #{latest_release} && git diff #{old_rev} #{new_rev} --name-only | cat").include?('asset')
+ gemfile_changed = capture("cd #{latest_release} && git diff #{old_rev} #{new_rev} --name-only | cat").include?('Gemfile.lock')
+ if assets_changed || (gemfile_changed && Capistrano::CLI.ui.ask("Gemfile changed. Enter 'yes' to precomple assets?") == 'yes')
+ run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile"
+ else
+ logger.info 'Skipping asset precompilation because there were no asset changes.'
+ end
end
end
end

0 comments on commit 4ee9d45

Please sign in to comment.