Skip to content

Instantly share code, notes, and snippets.

@dakatsuka
Created May 13, 2011 17:09
Show Gist options
  • Save dakatsuka/970910 to your computer and use it in GitHub Desktop.
Save dakatsuka/970910 to your computer and use it in GitHub Desktop.
Capfile
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 -RpL #{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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment