Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

for cached local copies, do the exclude and the copy in the same step…

…, it is much faster

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@9005 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 9e07fd2a231d8122d55376cc53596ba9db44fffd 1 parent dcee6b3
Jamis Buck jamis authored
11 lib/capistrano/recipes/deploy/strategy/copy.rb
View
@@ -60,7 +60,10 @@ def deploy!
while queue.any?
item = queue.shift
name = File.basename(item)
+
next if name == "." || name == ".."
+ next if copy_exclude.any? { |pattern| File.fnmatch(pattern, item) }
+
if File.directory?(item)
queue += Dir.glob("#{item}/*", File::FNM_DOTMATCH)
FileUtils.mkdir(File.join(destination, item))
@@ -72,11 +75,11 @@ def deploy!
else
logger.debug "getting (via #{copy_strategy}) revision #{revision} to #{destination}"
system(command)
- end
- if copy_exclude.any?
- logger.debug "processing exclusions..."
- copy_exclude.each { |pattern| FileUtils.rm_rf(File.join(destination, pattern)) }
+ if copy_exclude.any?
+ logger.debug "processing exclusions..."
+ copy_exclude.each { |pattern| FileUtils.rm_rf(File.join(destination, pattern)) }
+ end
end
File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) }
10 test/deploy/strategy/copy_test.rb
View
@@ -200,9 +200,8 @@ def test_with_copy_cache_with_excludes_should_not_copy_excluded_files
FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890")
- prepare_directory_tree!("/temp/dir/captest")
+ prepare_directory_tree!("/temp/dir/captest", true)
- FileUtils.expects(:rm_rf).with("/temp/dir/1234567890/*/bar.txt")
prepare_standard_compress_and_copy!
@strategy.deploy!
end
@@ -217,8 +216,11 @@ def prepare_directory_tree!(cache, exclude=false)
FileUtils.expects(:ln).with("#{cache}/foo.txt", "/temp/dir/1234567890/foo.txt")
Dir.expects(:glob).with("app/*", File::FNM_DOTMATCH).returns(["app/.", "app/..", "app/bar.txt"])
- File.expects(:directory?).with("app/bar.txt").returns(false)
- FileUtils.expects(:ln).with("#{cache}/app/bar.txt", "/temp/dir/1234567890/app/bar.txt")
+
+ unless exclude
+ File.expects(:directory?).with("app/bar.txt").returns(false)
+ FileUtils.expects(:ln).with("#{cache}/app/bar.txt", "/temp/dir/1234567890/app/bar.txt")
+ end
end
def prepare_standard_compress_and_copy!
Please sign in to comment.
Something went wrong with that request. Please try again.