Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow :copy_exclude to work for both normal and cached copies

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@8994 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 8e639fe39340a968abae04fd12db71703f617280 1 parent bf89d31
@jamis jamis authored
View
6 lib/capistrano/recipes/deploy/strategy/copy.rb
@@ -61,7 +61,6 @@ def deploy!
item = queue.shift
name = File.basename(item)
next if name == "." || name == ".."
- next if copy_exclude.any? { |pattern| pattern.is_a?(Regexp) ? item =~ pattern : File.fnmatch?(pattern, item, File::FNM_DOTMATCH) }
if File.directory?(item)
queue += Dir.glob("#{item}/*", File::FNM_DOTMATCH)
FileUtils.mkdir(File.join(destination, item))
@@ -75,6 +74,11 @@ def deploy!
system(command)
end
+ if copy_exclude.any?
+ logger.debug "processing exclusions..."
+ copy_exclude.each { |pattern| FileUtils.rm_rf(File.join(destination, pattern)) }
+ end
+
File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) }
logger.trace "compressing #{destination} to #{filename}"
View
20 test/deploy/strategy/copy_test.rb
@@ -24,6 +24,17 @@ def test_deploy_with_defaults_should_use_tar_gz_and_checkout
@strategy.deploy!
end
+ def test_deploy_with_exclusions_should_remove_patterns_from_destination
+ @config[:copy_exclude] = ".git"
+ Dir.expects(:tmpdir).returns("/temp/dir")
+ @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
+ @strategy.expects(:system).with(:local_checkout)
+
+ FileUtils.expects(:rm_rf).with("/temp/dir/1234567890/.git")
+ prepare_standard_compress_and_copy!
+ @strategy.deploy!
+ end
+
def test_deploy_with_export_should_use_tar_gz_and_export
Dir.expects(:tmpdir).returns("/temp/dir")
@config[:copy_strategy] = :export
@@ -189,8 +200,9 @@ 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", true)
+ prepare_directory_tree!("/temp/dir/captest")
+ FileUtils.expects(:rm_rf).with("/temp/dir/1234567890/*/bar.txt")
prepare_standard_compress_and_copy!
@strategy.deploy!
end
@@ -205,10 +217,8 @@ 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"])
- 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
+ File.expects(:directory?).with("app/bar.txt").returns(false)
+ FileUtils.expects(:ln).with("#{cache}/app/bar.txt", "/temp/dir/1234567890/app/bar.txt")
end
def prepare_standard_compress_and_copy!
Please sign in to comment.
Something went wrong with that request. Please try again.