Created
March 24, 2013 20:18
-
-
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..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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