LoginSignup
0
3

More than 3 years have passed since last update.

SVNをGitに移行するときにsvn.authorsfileに設定するファイルを作る方法

Posted at
  • 環境
    • Windows10 64bit
    • コマンドを使うのはGit Bash for Windows

作りたいのはSVNとGitでのユーザ情報のマッピングファイル

ubversion ではコミットした人すべてがシステム上にユーザーを持っており、それがコミット情報として記録されます。たとえば先ほどの節のサンプルで言うと schacon がそれで、blame の出力や git svn log の出力に含まれています。これをうまく Git の作者データとしてマップするには、Subversion のユーザーと Git の作者のマッピングが必要です。
Git - Git への移行

作りたいのはこんなファイル
schacon = Scott Chacon <schacon@example.jp>
selse = Someo Nelse <selse@example.jp>

1.SVNコマンドをインストールする

  1. サイトからApache Subversion command line toolsをダウンロードするimage.png
  2. ダウンロードした.zipを解凍して任意のディレクトリに格納する
  3. .bash_profileにPATHを通す
$ cat ~/.bash_profile
SVN_PATH="C:\任意のディレクトリ\Apache-Subversion-1.11.1\bin"
export PATH=$PHP_PATH:$PATH:$SVN_PATH

# .bash_profileを反映する
$ source ~/.bash_profile

# 確認する
$ svn --version
svn, version 1.11.1 (r1850623)
   compiled Feb  1 2019, 13:37:32 on x86/x86_64-microsoft-windows6.1.7601

Copyright (C) 2019 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_svn : Module for accessing a repository using the svn network protocol.
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - using serf 1.3.9 (compiled with 1.3.9)
  - handles 'http' scheme
  - handles 'https' scheme

The following authentication credential caches are available:

* Wincrypt cache in C:\Users\ponsuke\AppData\Roaming\Subversion

2.履歴情報を加工して

$ svn log --xml https://{SVNのパス} | grep "<author" | sort -u | perl -pe 's/<author>(.*?)<\/author>/$1 = $1 <$1\@example.jp>/g' > users.txt

まずログを XML フォーマットで出力します。その中から作者を捜して重複を省き、XML を除去します (ちょっと見ればわかりますが、これは grep や sort、そして perl といったコマンドが使える環境でないと動きません)。この出力を users.txt にリダイレクトし、そこに Git のユーザーデータを書き足していきます。
Git - Git への移行

3.使う

# クローンの時に使ったり
$ git svn clone http://my-project.googlecode.com/svn/ --authors-file=users.txt --no-metadata -s my_project
# 設定ファイルに設定したりして使う
$ git config --global svn.authorsfile ~/.svnauthors
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3