Handy Subversion Rake task

Just read a post from David at Planet Argon showing a way to add un-added files 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.

6 comments ↓

#1 Mark Lussier on 08.01.06 at 7:44 pm

I liked this so much I rolled it into a quick plugin so I can put it in each of my projects.. I stuck it here

./script/plugin install -x https://svn2.cvsdude.com/lussiema/plugins/subversionext

#2 Jamie on 08.01.06 at 8:19 pm

Glad you liked it. It’s the simple things that make life easier.

#3 Chris Anderson on 08.02.06 at 5:06 pm

Jamie,

I’ve got a svn_tools plugin that does all that and more.

rake svn:add / svn:del / svn:commit are the basics, but it also will bootstrap your application into a repository and ignore all the proper file in one fell swoop.

http://jchris.mfdz.com/articles/2006/07/21/subversion-tools-plugin

#4 Tom Brice on 08.02.06 at 10:01 pm

There is this too:

http://re.visioni.st/articles/2006/06/25/rake-task-easily-configure-subversion

We (as in the Rails communtiy) really need a better way to track plugins.

#5 Jamie on 08.02.06 at 11:06 pm

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.

#6 askegg on 08.04.06 at 5:27 am

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