Skip to content

Instantly share code, notes, and snippets.

@nicklegr
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save nicklegr/664e4d350a5d253d42d9 to your computer and use it in GitHub Desktop.

Select an option

Save nicklegr/664e4d350a5d253d42d9 to your computer and use it in GitHub Desktop.
svnリポジトリのダンプ → gitレポジトリ の変換
require 'fileutils'
# カレントにauthors.txtを作る
# svnadminのヘルプを参照
have_trunk = %w|
(trunkがあるリポジトリを列挙)
|
# 1. trunkがない
# 2. 最初はルートにファイルを作り、途中のリビジョンでtrunkに移動されている
# 3. vendorなど、ブランチがルート直下にある
# 2,3の場合、trunkを指定すると一部の履歴が消えてしまう
def run(cmd)
system(cmd)
raise if $? != 0
end
Dir.glob("dump/*.dump").each do |dump|
repos = File.basename(dump, ".*")
FileUtils.mkdir_p("svn_repos")
run("svnadmin create svn_repos/#{repos}")
run("svnadmin load svn_repos/#{repos} < #{dump}")
option = "--prefix=origin/ --no-metadata --localtime -A authors.txt"
option += " -Ttrunk" if have_trunk.include?(repos)
FileUtils.mkdir_p("git_repos")
run("git svn clone file:///full/path/to/svn_repos/#{repos} git_repos/#{repos} #{option}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment