Handy Subversion Rake task

Just read a post from “David”:http://david.planetargon.us at “Planet Argon”:http://planetargon.us/ showing a way to “add un-added files”:http://david.planetargon.us/articles/2006/07/28/i-love-shell-scripting in your Subversion working copy.
I have made this into a simple rake task:

namespace :svn do
  desc "Adds all files with an svn status flag of '?'"
  task(:add_new) { `svn status | awk '/\\?/ {print $2}' | xargs svn add` }
end

Just drop this code in a file called subversion.rake inside the tasks directory. Now you can run rake svn:add_new which will add all new files with an svn status flag of ‘?’ in your working copy.

Join the conversation

6 Comments

  1. Thanks for these, I didn’t realise they existed. It makes you wonder what other useful plugins are out there which have been left undiscovered.

  2. Is there any way to map the rake tasks to the capistrano/scm libraries?
    I have been thinking about creating a config file (maybe config/repository.rb?) then getting rake to read the config and use the capistrano libraries to checkin/checkout/update/etc from source control.
    The config would look something like:
    repository: http://dev.rubyonrails.org/svn/rails/trunk
    adapter: svn
    username: askegg
    password: mypassword
    and enable:
    rake checkout/checkin/update/diff/etc
    Unfortunately, I do not have the skills with ruby/rails to pull this off (yet). Any takers, or is this a bad idea?

Leave a comment

Your e-mail address will not be published. Required fields are marked *