Skip to content

Commit

Permalink
Make deploy:upload use the upload() helper for more efficient directo…
Browse files Browse the repository at this point in the history
…ry processing.
  • Loading branch information
jamis committed Jun 6, 2008
1 parent 7b41797 commit 919f868
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,5 +1,7 @@
*unreleased*

* Make deploy:upload use the upload() helper for more efficient directory processing [Jamis Buck]

* Make deploy:upload accept globs [Mark Imbriaco]

* Make sure the host is reported with the output from scm_run [Jamis Buck]
Expand Down
21 changes: 8 additions & 13 deletions lib/capistrano/recipes/deploy.rb
Expand Up @@ -233,24 +233,19 @@ def try_sudo(command=nil)
To use this task, specify the files and directories you want to copy as a \
comma-delimited list in the FILES environment variable. All directories \
will be processed recursively, with all files being pushed to the \
deployment servers. Any file or directory starting with a '.' character \
will be ignored.
deployment servers.
$ cap deploy:upload FILES=templates,controller.rb
Dir globs are also supported:
$ cap deploy:upload FILES='config/apache/*.conf'
DESC
task :upload, :except => { :no_release => true } do
files = (ENV["FILES"] || "").
split(",").
map { |f| f.strip!; Dir[ File.directory?(f) ? "#{f}/**/*" : f ]}.
flatten.
reject { |f| File.directory?(f) || File.basename(f)[0] == ?. }
files = (ENV["FILES"] || "").split(",").map { |f| Dir[f.strip] }.flatten
abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty?

abort "Please specify at least one file to update (via the FILES environment variable)" if files.empty?

files.each do |file|
content = File.open(file, "rb") { |f| f.read }
put content, File.join(current_path, file)
end
files.each { |file| top.upload(file, File.join(current_path, file)) }
end

desc <<-DESC
Expand Down

0 comments on commit 919f868

Please sign in to comment.