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:
-
require 'find'
-
require 'fileutils'
-
-
def find_and_delete(path, pattern)
-
Find.find(path) do |f|
-
if !File.file?(f) and f[pattern]
-
FileUtils.rm_rf(f)
-
end
-
end
-
end
-
-
# print all the ruby files
-
find_and_delete(".", /\.svn$/)