Skip to content

Instantly share code, notes, and snippets.

@NewAlexandria
Created March 24, 2013 20:18
Show Gist options
  • Save NewAlexandria/5233341 to your computer and use it in GitHub Desktop.
Save NewAlexandria/5233341 to your computer and use it in GitHub Desktop.
And then there was this time I had to mass-convert svn repos..
#!/usr/bin/env ruby
require 'fileutils'
path_base = ARGV[0] || '~/Sources'
server_path = ARGV[1]
repo_list = ARGV[2] || 'svn_repo_list'
svn_dir = File.expand_path File.join(path_base,'/svn')
git_dir = File.expand_path File.join(path_base,'/git')
unless File.exists? auth_file
puts 'you will need to build an authors file with:'
puts %{svn log --quiet ${ARGV[1]} | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | uniq | sort}
exit
end
svn_list = File.open(repo_list).map {|l| l.strip }
FileUtils.mkdir_p svn_dir
FileUtils.mkdir_p git_dir
Dir.chdir git_dir do |d|
svn_list.map do |repo|
puts "making dir, #{repo}"
FileUtils.mkdir_p repo
Dir.chdir repo do |repo_dir|
`svn2git #{server_path}#{repo} --verbose --authors #{auth_file}`
end
puts "done\r\r"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment