mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Added :copy_remote_dir for :copy strategy to indicate where the file should be copied to
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@7131 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
58ad087a10
commit
5089e08d95
3 changed files with 31 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Add :copy_remote_dir variable for the :copy strategy, to indicate where the archive should be copied to on the remote servers [Jamis Buck]
|
||||||
|
|
||||||
* Make the awk use in the dependencies code work with POSIX awk [mcornick]
|
* Make the awk use in the dependencies code work with POSIX awk [mcornick]
|
||||||
|
|
||||||
* Make variable accesses thread safe [via Adrian Danieli]
|
* Make variable accesses thread safe [via Adrian Danieli]
|
||||||
|
|
|
@ -83,10 +83,16 @@ module Capistrano
|
||||||
@tmpdir ||= configuration[:copy_dir] || Dir.tmpdir
|
@tmpdir ||= configuration[:copy_dir] || Dir.tmpdir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The directory on the remote server to which the archive should be
|
||||||
|
# copied
|
||||||
|
def remote_dir
|
||||||
|
@remote_dir ||= configuration[:copy_remote_dir] || "/tmp"
|
||||||
|
end
|
||||||
|
|
||||||
# The location on the remote server where the file should be
|
# The location on the remote server where the file should be
|
||||||
# temporarily stored.
|
# temporarily stored.
|
||||||
def remote_filename
|
def remote_filename
|
||||||
@remote_filename ||= "/tmp/#{File.basename(filename)}"
|
@remote_filename ||= File.join(remote_dir, File.basename(filename))
|
||||||
end
|
end
|
||||||
|
|
||||||
# The compression method to use, defaults to :gzip.
|
# The compression method to use, defaults to :gzip.
|
||||||
|
|
|
@ -121,4 +121,26 @@ class DeployStrategyCopyTest < Test::Unit::TestCase
|
||||||
|
|
||||||
@strategy.deploy!
|
@strategy.deploy!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_deploy_with_copy_remote_dir_should_copy_to_that_dir
|
||||||
|
@config[:copy_remote_dir] = "/somewhere/else"
|
||||||
|
Dir.expects(:tmpdir).returns("/temp/dir")
|
||||||
|
Dir.expects(:chdir).yields
|
||||||
|
@source.expects(:checkout).returns(:local_checkout)
|
||||||
|
|
||||||
|
@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(: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(:read).with("/temp/dir/1234567890.tar.gz").returns(:mock_file_contents)
|
||||||
|
|
||||||
|
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
||||||
|
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
||||||
|
|
||||||
|
@strategy.deploy!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue