creative-co / mana

Configuration management with Chef & Capistrano
MIT License
1 stars 5 forks source link

Add deployment strategy hack to default Capfile template or mention it in a readme. #2

Closed antlypls closed 11 years ago

antlypls commented 11 years ago

Since without it capistrano produces insane error about commiting Gemfile.lock to repo.

require 'capistrano/recipes/deploy/strategy/remote_cache'

class RemoteCacheSubdir < Capistrano::Deploy::Strategy::RemoteCache

  private

  def repository_cache_subdir
    if configuration[:deploy_subdir] then
      File.join(repository_cache, configuration[:deploy_subdir])
    else
      repository_cache
    end
  end

  def copy_repository_cache
    logger.trace "copying the cached version to #{configuration[:release_path]}"
    if copy_exclude.empty?
      run "cp -RPp #{repository_cache_subdir} #{configuration[:release_path]} && #{mark}"
    else
      exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ')
      run "rsync -lrpt #{exclusions} #{repository_cache_subdir}/* #{configuration[:release_path]} && #{mark}"
    end
  end

end

set :strategy, RemoteCacheSubdir.new(self)