SubGitでGitLabにSubversionの歴史を持ってくる
基本的には以下のドキュメントを読んで実行すればOK
importの場合もmirrorのドキュメントの方法を取ればbranchesなどの設定ができます。
(その場合は最後にuninstallの実行が必要)
手順
- GitLabでプロジェクトを作成
- gitユーザで先程作ったプロジェクトのリポジトリがあるディレクトリに移動
$ cd /var/opt/gitlab/git-data/repositories/GitLabのグループ
- subgitのconfigureコマンドを実行
$ subgit configure [svnのURL] [gitのbareリポジトリのパス]
- configファイルを修正(subgit/config)
configファイルはgitリポジトリのsubgit/configにあります
trunkやbranchesのパスが特殊な場合はここで修正します - passwdファイルを修正(subgit/passwd)
gitからsubversionに同期をとるためのSubversionの設定ファイルです
passwdファイルの先頭のユーザ情報を使って初回importが行われるようです
そのため、先頭ユーザはimportするSubversionリポジトリのトップの読み込み権限が必要です - authors.txtファイルを修正(subgit/authors.txt)
Subversionのコミットユーザとgit(GitLab)のユーザをひもづけるためのファイルです - subgitのinstallコマンドを実行
$ subgit install [gitのbareリポジトリのパス]
- (ライセンスキーがある場合)ライセンスキーをインストール
root権限で行うことに注意する
# subgit register --key [ライセンスキーのパス] [gitのbareリポジトリのパス]
- (importのみの場合)subgitをアンインストール
$ subgit uninstall [gitのbareリポジトリのパス]
ファイル設定例
- author.txt
svnUser = Git User <user@example.com> hoge = hoge hoge <hoge@example.com>
- passwd
- Subversionのパスワードを平文で入力する必要があります(セキュリティ的に問題がありますが…)
svnUserName svnUserPassword hoge hogepassword
- config
- 基本的にはそのままでOK
- trunk, branches, tagsの構成が特殊な場合はここでマッピングを修正する
- git上の作業ブランチをSubversionに同期させたくない場合は、以下のようにsvnプレフィックスをつけることで回避できます
→参考:git - SubGit: How to exclude branches? - Stack Overflow
[svn] trunk = trunk:refs/heads/svn/master branches = branches/*:refs/heads/svn/* tags = tags/*:refs/tags/svn/*
実行例
ユーザの確認
$ whoami git
1.ディレクトリがあるパスまで移動
$ cd /var/opt/gitlab/git-data/repositories/
3.subgit configureを実行
$ subgit configure http://hoge/svn/svnrepo/ gitrepo.git SubGit version 3.2.4 ('Bobique') build #3670 Configuring writable Git mirror of remote Subversion repository: Subversion repository URL : http://hoge/svn/svnrepo Git repository location : gitrepo.git Git repository is served by GitLab, hooks will be installed into 'custom_hooks' directory. CONFIGURATION SUCCESSFUL To complete SubGit installation do the following: 1) Adjust Subversion to Git branches mapping if necessary: /var/opt/gitlab/git-data/repositories/hoge/gitrepo.git/subgit/config 2) Define at least one Subversion credentials in default SubGit passwd file at: /var/opt/gitlab/git-data/repositories/hoge/gitrepo.git/subgit/passwd OR configure SSH or SSL credentials in the [auth] section of: /var/opt/gitlab/git-data/repositories/hoge/gitrepo.git/subgit/config 3) Optionally, add custom authors mapping to the authors.txt file(s) at: /var/opt/gitlab/git-data/repositories/hoge/gitrepo.git/subgit/authors.txt 4) Run SubGit 'install' command: subgit install gitrepo.git
7.設定ファイルを修正した後、subgitのinstallコマンドを実行
$ subgit install gitrepo.git
8.(キーがある場合)rootユーザでライセンスキーをインストール
# subgit register --key subgit.key gitrepo.git SubGit version 3.2.4 ('Bobique') build #3670 Detecting committers in 2 repositories... Registration information: Registered for: xxxxx Purchase ID: xxxxx Git Committers Limit: xxxxx Free upgrades until: xxxxx REGISTRATION SUCCESSFUL Thank you for registering SubGit! Visit http://www.subgit.com/ in case you have any questions and for more information on SubGit.