Capistrano.configuration(:must_exist).load do desc "Setup svn repository" task :setup_svn, :roles => :scm do dir = "#{deploy_to}/repos" run "mkdir -p #{dir}" run "chmod 770 #{dir}" run "svnadmin create #{dir}" run "chmod -R g+w #{dir}/db/transactions" run "chmod g+w #{dir}/db/write-lock" run "chmod -R g+w #{dir}/db/revs" run "chmod -R g+w #{dir}/db/revprops" run "chmod g+w #{dir}/db" end desc "Import code into svn repository." task :import_svn do new_path = "../#{application}_mmm" tags = repository.sub("trunk", "tags") branches = repository.sub("trunk", "branches") puts "Adding branches and tags" system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}" puts "Importing application." system "svn import #{repository} -m 'Import'" puts "Checking out to new directory." system "svn co #{repository} #{new_path}" cwd = Dir.getwd Dir.chdir new_path puts "removing log directory contents from svn" system "svn remove log/*" puts "ignoring log directory" system "svn propset svn:ignore '*.log' log/" system "svn update log/" puts "removing tmp directory from svn" system "svn remove tmp/" puts "ignoring tmp directory" system "svn propset svn:ignore '*' tmp/" system "svn update tmp/" puts "committing changes" system "svn commit -m 'Removed and ignored log files and tmp'" Dir.chdir cwd puts "Your repository is: #{repository}" puts "Please change to your new working directory: #{new_path}" end end