Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Applied Jeremy's patch from Lighthouse #77

  • Loading branch information...
commit 7aadfcd4a1b3a5f8f9533fde2b330d1f70425ab7 1 parent 75fe3af
@leehambley leehambley authored
View
7 lib/capistrano/recipes/deploy/strategy/copy.rb
@@ -182,10 +182,13 @@ def remote_filename
# The compression method to use, defaults to :gzip.
def compression
+ remote_tar = configuration[:copy_remote_tar] || 'tar'
+ local_tar = configuration[:copy_local_tar] || 'tar'
+
type = configuration[:copy_compression] || :gzip
case type
- when :gzip, :gz then Compression.new("tar.gz", %w(tar czf), %w(tar xzf))
- when :bzip2, :bz2 then Compression.new("tar.bz2", %w(tar cjf), %w(tar xjf))
+ when :gzip, :gz then Compression.new("tar.gz", [local_tar, 'czf'], [remote_tar, 'xzf'])
+ when :bzip2, :bz2 then Compression.new("tar.bz2", [local_tar, 'cjf'], [remote_tar, 'xjf'])
when :zip then Compression.new("zip", %w(zip -qr), %w(unzip -q))
else raise ArgumentError, "invalid compression type #{type.inspect}"
end
View
44 test/deploy/strategy/copy_test.rb
@@ -14,6 +14,50 @@ def setup
@config.stubs(:source).returns(@source)
@strategy = Capistrano::Deploy::Strategy::Copy.new(@config)
end
+
+ def test_deploy_with_defaults_should_use_remote_gtar
+ @config[:copy_remote_tar] = 'gtar'
+
+ Dir.expects(:tmpdir).returns("/temp/dir")
+ @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
+ @strategy.expects(:system).with(:local_checkout)
+
+ Dir.expects(:chdir).with("/temp/dir").yields
+ @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
+ @strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz")
+ @strategy.expects(:run).with("cd /u/apps/test/releases && gtar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
+
+ mock_file = mock("file")
+ mock_file.expects(:puts).with("154")
+ File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
+
+ FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
+ FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
+
+ @strategy.deploy!
+ end
+
+ def test_deploy_with_defaults_should_use_local_gtar
+ @config[:copy_local_tar] = 'gtar'
+
+ Dir.expects(:tmpdir).returns("/temp/dir")
+ @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
+ @strategy.expects(:system).with(:local_checkout)
+
+ Dir.expects(:chdir).with("/temp/dir").yields
+ @strategy.expects(:system).with("gtar czf 1234567890.tar.gz 1234567890")
+ @strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz")
+ @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
+
+ mock_file = mock("file")
+ mock_file.expects(:puts).with("154")
+ File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
+
+ FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
+ FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
+
+ @strategy.deploy!
+ end
def test_deploy_with_defaults_should_use_tar_gz_and_checkout
Dir.expects(:tmpdir).returns("/temp/dir")
Please sign in to comment.
Something went wrong with that request. Please try again.