Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails at :scm is :none and ssh_options[:keys] #23

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Capistrano rsync_with_remote_cache Deployment Strategy
= Öz Capistrano oz_rsync_with_remote_cache Deployment Strategy

== Description

Expand All @@ -20,7 +20,7 @@ This gem is tested on Mac OS X and Linux. Windows is neither tested nor supporte

== Installation

gem install capistrano_rsync_with_remote_cache
gem install oz_capistrano_rsync_with_remote_cache

== Usage

Expand Down
25 changes: 19 additions & 6 deletions lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def copy_remote_cache
end

def rsync_command_for(server)
"rsync #{rsync_options} --rsh='ssh -p #{ssh_port(server)}' #{local_cache_path}/ #{rsync_host(server)}:#{repository_cache_path}/"
"rsync #{rsync_options} --rsh='ssh -p #{ssh_port(server)} #{ssh_key} #{ssh_config_file}' '#{local_cache_path}/' #{rsync_host(server)}:#{repository_cache_path}/"
end

def mark_local_cache
Expand All @@ -54,6 +54,14 @@ def mark_local_cache
def ssh_port(server)
server.port || ssh_options[:port] || 22
end

def ssh_key
ssh_options[:keys] ? "-i #{ssh_options[:keys]}" : ""
end

def ssh_config_file
ssh_options[:config] ? "-F #{ssh_options[:config]}" : ""
end

def local_cache_path
File.expand_path(local_cache)
Expand Down Expand Up @@ -106,12 +114,17 @@ def check!
private

def command
if local_cache_valid?
source.sync(revision, local_cache_path)
elsif !local_cache_exists?
"mkdir -p #{local_cache_path} && #{source.checkout(revision, local_cache_path)}"
if configuration[:scm] == :none
#If scm is NONE, we don't need to sync
logger.info ":scm is none and we dont need to sync"
else
raise InvalidCacheError, "The local cache exists but is not valid (#{local_cache_path})"
if local_cache_valid?
source.sync(revision, local_cache_path)
elsif !local_cache_exists?
"mkdir -p #{local_cache_path} && #{source.checkout(revision, local_cache_path)}"
else
raise InvalidCacheError, "The local cache exists but is not valid (#{local_cache_path})"
end
end
end
end
Expand Down