Browse code

Rsync --delete option can be turned off in Rakefile configuration and users can exclude directories from sync by adding an rsync-exclude file to their root directory. fixes #247

Brandon Mathis authored on 11/12/2011 at 00:18:34
Showing 1 changed files
... ...
@@ -7,6 +7,7 @@ require "stringex"
7 7
 ssh_user       = "user@domain.com"
8 8
 ssh_port       = "22"
9 9
 document_root  = "~/website.com/"
10
+rsync_delete   = true
10 11
 deploy_default = "rsync"
11 12
 
12 13
 # This will be configured for you when you run config_deploy
... ...
@@ -116,7 +117,7 @@ task :new_page, :filename do |t, args|
116 116
   raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
117 117
   args.with_defaults(:filename => 'new-page')
118 118
   page_dir = [source_dir]
119
-  if args.filename.downcase =~ /(^.+\/)?(.+)/ 
119
+  if args.filename.downcase =~ /(^.+\/)?(.+)/
120 120
     filename, dot, extension = $2.rpartition('.').reject(&:empty?)         # Get filename and extension
121 121
     title = filename
122 122
     page_dir.concat($1.downcase.sub(/^\//, '').split('/')) unless $1.nil?  # Add path to page_dir Array
... ...
@@ -231,8 +232,12 @@ end
231 231
 
232 232
 desc "Deploy website via rsync"
233 233
 task :rsync do
234
+  exclude = ""
235
+  if File.exists?('./rsync-exclude'))
236
+    exclude = "--exclude-from '#{File.expand_path('./rsync-exclude')}'"
237
+  end
234 238
   puts "## Deploying website via Rsync"
235
-  ok_failed system("rsync -avze 'ssh -p #{ssh_port}' --delete #{public_dir}/ #{ssh_user}:#{document_root}")
239
+  ok_failed system("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}")
236 240
 end
237 241
 
238 242
 desc "deploy public directory to github pages"