Permalink
Browse files

allow server port number to override global ssh option

  • Loading branch information...
1 parent db16b24 commit 15278efef9319079aa910c7801cfcf59ebb663c2 S. Brent Faulkner committed with reagent Jun 4, 2010
@@ -44,15 +44,15 @@ def copy_remote_cache
end
def rsync_command_for(server)
- "rsync #{rsync_options} --rsh='ssh -p #{ssh_port}' #{local_cache_path}/ #{rsync_host(server)}:#{repository_cache_path}/"
+ "rsync #{rsync_options} --rsh='ssh -p #{ssh_port(server)}' #{local_cache_path}/ #{rsync_host(server)}:#{repository_cache_path}/"
end
def mark_local_cache
File.open(File.join(local_cache_path, 'REVISION'), 'w') {|f| f << revision }
end
- def ssh_port
- ssh_options[:port] || 22
+ def ssh_port(server)
+ server.port || ssh_options[:port] || 22
end
def local_cache_path
@@ -103,12 +103,20 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
should "know the default SSH port" do
@strategy.stubs(:ssh_options).with().returns({})
- @strategy.ssh_port.should == 22
+ server = stub(:port => nil)
+ @strategy.ssh_port(server).should == 22
end
should "be able to override the default SSH port" do
@strategy.stubs(:ssh_options).with().returns({:port => 95})
- @strategy.ssh_port.should == 95
+ server = stub(:port => nil)
+ @strategy.ssh_port(server).should == 95
+ end
+
+ should "be able to override the default SSH port for each server" do
+ @strategy.stubs(:ssh_options).with().returns({:port => 95})
+ server = stub(:port => 123)
+ @strategy.ssh_port(server).should == 123
end
should "know the default repository cache" do

0 comments on commit 15278ef

Please sign in to comment.