LoginSignup
1
0

More than 5 years have passed since last update.

【Subversion】Capistranoのデプロイで必要ない時はasset precompileをしない

Last updated at Posted at 2012-06-06

なにとなくsvnでかいてみた。
動作保証はできませぬ。
もっと簡潔な書き方あるような...

precompile.rb
 namespace :assets do                                                              
    task :precompile, :roles => :webs do                                            
      revs = []                                                                     
      [                                                                             
        current_path,                                                               
        release_path                                                                
      ].each{|i|
        revs << capture("cd #{i} && svnversion").chomp.gsub(/M/, '')
      }       
      lines = revs.uniq.size < 2 ? 0 :                                              
        capture("cd #{release_path} && svn log -v -r#{revs.join(':')} | grep 'app/assets' | wc -l").to_i                                                                                                    
      if lines > 0                                                                  
        p "precompile"                                                              
        run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
      else                                                                          
        p "skipping precompile"                                                     
      end                                                                           
    end                                                                             
  end                  
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0