Rake task to set up SVN
Posted by Jason, Fri May 18 07:56:00 UTC 2007
It seems like I found a way to DRY up my rails creation process. Every time I would set up a new application that was going to be imported into subversion, I would have to go through the same propset svn:ignore routine. I found this script in another project, and thought it was worthy of attention. Now, all you have to do is drop the below code in a file called svn.rake in your lib/tasks directory and run it using "rake configure_for_svn" on your initial checkout.
desc "Configure Subversion for Rails"
task :configure_for_svn do
system "svn remove log/*"
system "svn commit -m 'removing all log files from subversion'"
system 'svn propset svn:ignore "*.log" log/'
system "svn update log/"
system "svn commit -m 'Ignoring all files in /log/ ending in .log'"
system 'svn propset svn:ignore "*.db" db/'
system "svn update db/"
system "svn commit -m 'Ignoring all files in /db/ ending in .db'"
system "svn move config/database.yml config/database.example"
system "svn commit -m 'Moving database.yml to database.example'"
system 'svn propset svn:ignore "database.yml" config/'
system "svn update config/"
system "svn commit -m 'Ignoring database.yml'"
system "svn remove tmp/*"
system "svn commit -m 'Removing /tmp/ folder'"
system 'svn propset svn:ignore "*" tmp/'
end
desc "Add new files to subversion"
task :add_new_files do
system "svn status | grep '^\?' | sed\
-e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
end
desc "shortcut for adding new files"
task :add => [ :add_new_files ]
That should get you all cleaned up for the repository.
Enjoy!