diff --git a/CHANGELOG b/CHANGELOG index a0fac98e..61dc7cf8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *unreleased* +* Use upload() instead of put() with the copy strategy [Jamis Buck] + * Revert the "git fetch --tags" change, since it didn't work as expected [Jamis Buck] * Fix deploy:pending when using git SCM [Ryan McGeary] diff --git a/lib/capistrano/recipes/deploy/strategy/copy.rb b/lib/capistrano/recipes/deploy/strategy/copy.rb index 412edf2e..646f2931 100644 --- a/lib/capistrano/recipes/deploy/strategy/copy.rb +++ b/lib/capistrano/recipes/deploy/strategy/copy.rb @@ -87,8 +87,7 @@ module Capistrano logger.trace "compressing #{destination} to #{filename}" Dir.chdir(tmpdir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) } - content = File.open(filename, "rb") { |f| f.read } - put content, remote_filename + upload(filename, remote_filename) run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}" ensure FileUtils.rm filename rescue nil diff --git a/test/deploy/strategy/copy_test.rb b/test/deploy/strategy/copy_test.rb index 7566bca7..567f50ec 100644 --- a/test/deploy/strategy/copy_test.rb +++ b/test/deploy/strategy/copy_test.rb @@ -53,13 +53,12 @@ class DeployStrategyCopyTest < Test::Unit::TestCase @strategy.expects(:system).with(:local_checkout) @strategy.expects(:system).with("zip -qr 1234567890.zip 1234567890") - @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.zip") + @strategy.expects(:upload).with("/temp/dir/1234567890.zip", "/tmp/1234567890.zip") @strategy.expects(:run).with("cd /u/apps/test/releases && unzip -q /tmp/1234567890.zip && rm /tmp/1234567890.zip") mock_file = mock("file") mock_file.expects(:puts).with("154") File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file) - File.expects(:open).with("/temp/dir/1234567890.zip", "rb").yields(StringIO.new).returns(:mock_file_contents) FileUtils.expects(:rm).with("/temp/dir/1234567890.zip") FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") @@ -75,13 +74,12 @@ class DeployStrategyCopyTest < Test::Unit::TestCase @strategy.expects(:system).with(:local_checkout) @strategy.expects(:system).with("tar cjf 1234567890.tar.bz2 1234567890") - @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.bz2") + @strategy.expects(:upload).with("/temp/dir/1234567890.tar.bz2", "/tmp/1234567890.tar.bz2") @strategy.expects(:run).with("cd /u/apps/test/releases && tar xjf /tmp/1234567890.tar.bz2 && rm /tmp/1234567890.tar.bz2") mock_file = mock("file") mock_file.expects(:puts).with("154") File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file) - File.expects(:open).with("/temp/dir/1234567890.tar.bz2", "rb").yields(StringIO.new).returns(:mock_file_contents) FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.bz2") FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") @@ -97,13 +95,12 @@ class DeployStrategyCopyTest < Test::Unit::TestCase @strategy.expects(:system).with(:local_checkout) @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890") - @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.gz") + @strategy.expects(:upload).with("/other/path/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("/other/path/1234567890/REVISION", "w").yields(mock_file) - File.expects(:open).with("/other/path/1234567890.tar.gz", "rb").yields(StringIO.new).returns(:mock_file_contents) FileUtils.expects(:rm).with("/other/path/1234567890.tar.gz") FileUtils.expects(:rm_rf).with("/other/path/1234567890") @@ -119,13 +116,12 @@ class DeployStrategyCopyTest < Test::Unit::TestCase @strategy.expects(:system).with(:local_checkout) @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890") - @strategy.expects(:put).with(:mock_file_contents, "/somewhere/else/1234567890.tar.gz") + @strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/somewhere/else/1234567890.tar.gz") @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /somewhere/else/1234567890.tar.gz && rm /somewhere/else/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) - File.expects(:open).with("/temp/dir/1234567890.tar.gz", "rb").yields(StringIO.new).returns(:mock_file_contents) FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz") FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") @@ -226,13 +222,12 @@ class DeployStrategyCopyTest < Test::Unit::TestCase def prepare_standard_compress_and_copy! Dir.expects(:chdir).with("/temp/dir").yields @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890") - @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.gz") + @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) - File.expects(:open).with("/temp/dir/1234567890.tar.gz", "rb").yields(StringIO.new).returns(:mock_file_contents) FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz") FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")