Created
May 25, 2012 03:12
-
-
Save wilr/2785527 to your computer and use it in GitHub Desktop.
RemoteRsycCacheSubdir Capistrano Task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Load plugins | |
# | |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator | |
require 'railsless-deploy' | |
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } | |
load 'config/deploy' # remove this line to skip loading any of the default tasks | |
# | |
# Deploys a single folder from a git repository over rsync as the servers | |
# are behind firewalls | |
# | |
require 'capistrano/recipes/deploy/strategy/rsync_with_remote_cache' | |
class RemoteRsycCacheSubdir < Capistrano::Deploy::Strategy::RsyncWithRemoteCache | |
private | |
def repository_cache_subdir | |
if configuration[:deploy_subdir] then | |
File.join(repository_cache_path, configuration[:deploy_subdir]) | |
else | |
repository_cache_path | |
end | |
end | |
def copy_remote_cache | |
logger.trace "copying the cached version to #{configuration[:release_path]}" | |
if !configuration[:copy_exclude] || configuration[:copy_exclude].empty? | |
run "cp -RPp #{repository_cache_subdir} #{configuration[:release_path]} && #{mark}" | |
else | |
exclusions = configuration[:copy_exclude].map { |e| "--exclude=\"#{e}\"" }.join(' ') | |
run "rsync -lrpt #{exclusions} #{repository_cache_subdir}/* #{configuration[:release_path]} && #{mark}" | |
end | |
end | |
end | |
set :strategy, RemoteRsycCacheSubdir.new(self) | |
set :deploy_via, :rsync_with_remote_cache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment