]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
fix bug with rsync when leap command is run from other directories
authorelijah <elijah@riseup.net>
Sun, 20 Jan 2013 21:52:48 +0000 (13:52 -0800)
committerelijah <elijah@riseup.net>
Sun, 20 Jan 2013 21:52:48 +0000 (13:52 -0800)
lib/leap_cli/commands/deploy.rb
lib/leap_cli/remote/plugin.rb
vendor/supply_drop/lib/supply_drop/rsync.rb

index a7f6bc31884b1c8f5bf6a7a82863823b43232c46..37901f4b19fbd63e29c310832cf63f9dc61a5854 100644 (file)
@@ -88,6 +88,8 @@ module LeapCli
     end
 
     def calculate_includes_from_files(files)
+      return nil unless files and files.any?
+
       # prepend '/' (kind of like ^ for rsync)
       includes = files.collect {|file| '/' + file}
 
@@ -98,7 +100,7 @@ module LeapCli
         end
       end
 
-      # include all parent directories
+      # include all parent directories (required because of --exclude '*')
       includes.size.times do |i|
         path = File.dirname(includes[i])
         while(path != '/')
index 213c98130fc19754b268a2261af3168dc93336f9..c32b0beb34cc6a96831de6617d41969e1c61778b 100644 (file)
@@ -48,7 +48,10 @@ module LeapCli; module Remote; module Plugin
   #end
 
   #
-  # takes a block, yielded a server, that should return {:source => '', :dest => ''}
+  # takes a block, yielded a server, that should return a hash with various rsync options.
+  # supported options include:
+  #
+  #   {:source => '', :dest => '', :flags => '', :includes => [], :excludes => []}
   #
   def rsync_update
     SupplyDrop::Util.thread_pool_size = puppet_parallel_rsync_pool_size
@@ -76,7 +79,7 @@ module LeapCli; module Remote; module Plugin
 
       # run command
       logger.debug rsync_cmd
-      Dir.chdir(options[:chdir] || '.') do
+      Dir.chdir(options[:chdir] || Path.provider) do
         ok = system(rsync_cmd)
         failed_servers << server.host unless ok
       end
index 732a719ced36a2eb5fa71b37e14bfefa88af079f..a3d489800f950ec8bebe587b111ecb645677fa24 100644 (file)
@@ -18,11 +18,11 @@ module SupplyDrop
       end
 
       def excludes(patterns)
-        [patterns].flatten.map { |p| "--exclude='#{p}'" }
+        [patterns].flatten.compact.map { |p| "--exclude='#{p}'" }
       end
 
       def includes(patterns)
-        [patterns].flatten.map { |p| "--include='#{p}'" }
+        [patterns].flatten.compact.map { |p| "--include='#{p}'" }
       end
 
       def ssh_options(options)