Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping between git committers and SVN users

Tags:

git

svn

git-svn

Vincent Danen does mention the -A option when using git svn:

So using ~/git as a top-level directory for Git repositories [...] create an authors.txt file.
This file will map the names of Subversion committers to Git authors, resulting in a correct history of the imported Subversion repository.
For projects with a small number of committers, this is quite easy. For larger projects with a lot of committers, this may take some time. The syntax of the file would be:

user = Joe User <[email protected]>
vdanen = Vincent Danen <[email protected]>

The short name is the committer name for Subversion whereas the long form is the user’s full name and e-mail address, as used by Git.

The final step is to clone the Subversion repository, which creates a local Git repository based on it. Assuming your repository uses the standards of /trunk, /tags, and /branches, use:

# git svn clone --no-metadata -A authors.txt -t tags -b branches -T trunk https://svn.example.com/svn/repo

-A<filename>
--authors-file=<filename>

Syntax is compatible with the file used by git-cvsimport:

loginname = Joe User <[email protected]>

If this option is specified and git-svn encounters an SVN committer name that does not exist in the authors-file, git-svn will abort operation.
The user will then have to add the appropriate entry.
Re-running the previous git-svn command after the authors-file is modified should continue operation.

config key: svn.authorsfile

This should work for all git-svn commands, including git-svn dcommit (when you push to SVN) (Note: I have not tested it directly though).

Mohammed Gamal does report (in the comments) it is working, but without the --no-metadata option.


a second option is to provide a program / script which solves the mapping.

Very useful if there the number of committers is unknown but might be "generated" from the SVN committer name!

If … SVN committer name that does not exist in the authors-file, git svn will abort operation. The user will then have to add the appropriate entry. Re-running the previous git svn command after the authors-file is modified …

so, therefor we have:

--authors-prog=mapMyCompanyUsers.sh

To not have force every user to checkout / curl / wget'ting the map-Script first, you might provide something like this:

$(tmpMapFile="$TMPDIR/mapSvnUsersAutomatically.$$.sh" && echo -e '#!/bin/sh\necho $1" <"$1"@example.com>"' > $tmpMapFile && chmod +x $tmpMapFile && echo $tmpMapFile)

The clone will look like:

$ git svn clone -s --authors-prog=$(tmpMapFile="$TMPDIR/mapSvnUsersAutomatically.$$.sh" && echo -e '#!/bin/sh\necho $1" <"$1"@example.com>"' > $tmpMapFile && chmod +x $tmpMapFile && echo $tmpMapFile) https://svn.example.com/svn/repo/

This will force all mappings are exacly the same and SVN clones might be "shared" and merged via git!