Agile Tortoise

Greg Pierce’s blog

« LOL License      Tech refresh for the company site »

Strip “.svn” folder from Subversion working copy

It seems like there's probably a much easier way to do this, but I had a Rails project under Subversion, where I lost access to the original repository.  In a perfect world, you'd just do an export from the repo to get a clean copy of the code, but I could do that -- so I just wanted to strip out the ".svn" directories to make what I had on disk a clean version.  So I wrote the below. Seemed to work fine. Project now under Git. That is all.

RUBY:
  1. require 'find'
  2. require 'fileutils'
  3.  
  4. def find_and_delete(path, pattern)
  5.   Find.find(path) do |f|
  6.     if !File.file?(f) and f[pattern]
  7.       FileUtils.rm_rf(f)
  8.     end
  9.   end
  10. end
  11.  
  12. # print all the ruby files
  13. find_and_delete(".", /\.svn$/)

Tuesday, May 6th, 2008 at 8:32 pm and is filed under Misc. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply