Last active
August 29, 2015 14:11
-
-
Save nicklegr/664e4d350a5d253d42d9 to your computer and use it in GitHub Desktop.
svnリポジトリのダンプ → gitレポジトリ の変換
This file contains hidden or 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
| 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