The other day I needed to remove a mess of .svn directories from a project as I moved it from my personal box (using svn as the soure control) to the client’s source control system. This is a fairly frequent task, so attempting to be a “productive programmer” I decided that I would take the time to write a script to do this for me. After testing, it took about an hour to write… mainly because I tried to be too fancy, and tried a few things in Groovy I had not seen before. Overall, it was an hour well spent:
14 lines. I really like the eachDir and the eachFile methods on the File object… and there is even an eachFileRecurse. All I can say is: where the heck is the eachDirRecurse??? Oh well. It was still a good learning experience, and now I have a malleable tool next time I run into something similar.
Luis Lavena | 04-Apr-07 at 9:56 pm | Permalink
Matt, not to demise your code, but would ’svn export’ be shorter?
svn export /usr/matt/my_code_exported
Later,
L.
Jason | 05-Apr-07 at 2:28 am | Permalink
Learning Groovy aside, you should check out svn export.
Matt | 05-Apr-07 at 5:01 am | Permalink
Heh, learn something new everyday! Thanks guys!
Chris | 05-Apr-07 at 3:49 pm | Permalink
How about a groovy script to “svn rm” directories that only contain .svn subdirs?
barf | 05-Apr-07 at 6:48 pm | Permalink
Yeah, svn export. Or if you still need to clean up someone else’s mess use find:
$ find . -name .svn -exec rm -rf {} \;
Or something like that…
Matt | 05-Apr-07 at 8:09 pm | Permalink
Thanks Barf… that “or something like that” kinda worries me….
hohonuuli | 10-Apr-07 at 1:27 pm | Permalink
How about:
rm -rf $(find . -name .svn)