1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Use upload() instead of put() with the copy strategy

This commit is contained in:
Jamis Buck 2008-05-06 21:03:30 -06:00
parent 15e9ed54d8
commit 1f3fdf3079
3 changed files with 8 additions and 12 deletions

View file

@ -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]

View file

@ -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

View file

@ -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")