Table of Contents |
---|
SVN Users and Git Authors
Anchor | ||||
---|---|---|---|---|
|
Both Subversion and Git keep authors names in commits, but those authors differ.
In SVN, the author is being stored is stored as an unversioned revision property svn:author
. Every time a Subversion user makes a commit, SVN creates a new revision and sets this revision svn:author
property to that exact user's name, for example, johndoe:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
------------------------------------------------------------------------
r163 | johndoe | 2017-06-07 20:22:15 +0500 (Wed, 07 Jun 2017) | 1 line
Changed paths:
A /project
A /project/branches
A /project/tags
A /project/trunk
initial layout for the project
------------------------------------------------------------------------
????
$ svn proplist -v --revprop --revision 163
Unversioned properties on revision 163:
svn:author
johndoe
svn:date
2017-06-07T15:22:15.655243Z
svn:log
initial layout for the project
|
...
Pro Git book describes the difference between those names as follows: the author is the person who originally wrote the work, whereas the committer is the person who last applied the work. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit – you as the author, and the core member as the committer.
SubGit translates Git Up to the version 3.3.4 SubGit only used Git author name, so committer name doesn't mean much for the SVN-to-Git translation processso committer name did not mean much.
Since v.3.3.4 SubGit uses committer name for the author mapping by default. Since v.3.3.6 there's also an option to switch back to using author name for the mapping with the core.mapGitCommitter setting:
No Format |
---|
[core]
mapGitCommitter = true|false |
When it’s set to true (default), SubGit uses committer's name. Set it to false to make SubGit use author's name.
Info | ||
---|---|---|
| ||
Note, that SubGit uses authors names to count licensed users, see Licensing manual for details. |
Configuration options
Anchor | ||||
---|---|---|---|---|
|
All the configuration options reside in SubGit configuration file, that is situated in subgit subdirectory inside a newly created Git repository:
...
core.authorsFile
Anchor core.authorsFile core.authorsFile this option represents a path to the authors mapping file or authors mapping helper program. The path is either relative to the Git repository or absolute. The default value isauthors file is situated in SubGit directory:
No Format [core] authorsFile = subgit/authors.txt
There may be more that one
authorsFile
option set in the file:No Format [core] authorsFile = subgit/authors.txt authorsFile = /etc/authors.txt
All the mentioned files content is being merged into a full list. If an SVN username appears more than once – only its first occurrence will be applied. For example, if an SVN username
johndoe
appears in both authors files:No Format subgit/authors.txt johndoe = John Doe <johndoe@example.com> … /etc/authors.txt johndoe = John M. Doe <john_doe@example.com>
In this case, the SVN name
johndoe
is being mapped to Git nameJohn Doe <johndoe@example.com>
as it appears first in the list.
...
Automatic Authors Mapping Anchor AutoMapping AutoMapping
When SubGit starts translation between SVN and Git, it looks for authors mapping files or authors helper programs. If none of them present, it generates the mapping automatically, following these rules for the translation:
...
Similarly, Git commits that made by John Doe <johndoe@example.com> Git user appears in SVN with John Doe author name.
Authors File Anchor AuthorsFile AuthorsFile
The authors mapping file is a text file filled with SVN username - Git author pairs. Each pair maps SVN username to Git author like:
...
Again, every Git commit made by those authors will be translated with author set to jdoe.
SVN revisions made by jdoe
is always set to first matching Git user in the authors files
– John Doe <john_doe@example.com>
in this particular case.
Changes made to authors files are being applied immediately, there is no need to restart mirroring or reinstall SubGit.
Scriptable Authors Mapping
Anchor | ||||
---|---|---|---|---|
|
In addition to the authors filefiles, there 's is another way to provide establish SVN to Git authors mapping using authors helper program. The authors helper is an executable - script – script or binary - that – that is able to read data from standard input and provide send its work result to the standard output. The data helper reads from input and the data helper provides to output must fulfill certain formatInput and output data must fulfil the following formats:
for Git to Subversion mapping:
Author Name author email OUTPUT: SubversionuserNo Format INPUT:
author Name author email OUTPUT: subversion_user_name
for Subversion to Git mapping:
Subversionusername OUTPUT: Author Name authorNo Format INPUT:
subversion_user_name OUTPUT: author Name author email
Every time SubGit finds needs to map an author name during translation, it invokes the authors mapping helper program, passes the name to it and expects the helper to answer with matching author name.
The authors helper program might be extremely useful especially when you have many authors and the authors list is constantly changing - new – new users are being added, names and emails changes and so on. If you use some catalog to store accounts - LDAP– LDAP, Active Directory, OpenID and so forth - you – you can create a script that will gather needed information from the catalog and provide it to SubGit.
During On configuration or installation phase SubGit places simple creates a simple authors.sh
script into subgit/in samples
directory subdirectory. This script doesn't do much useful, it 's just some 'proof of concept' that demonstrates how input data is being read and output data provided.
Expand | ||
---|---|---|
|
...
| |
|
...
|
Depending on what was sent to its input script returns either Git author name and email or SVN short name. It can be extended to, say, receive the data from catalog or database thereby facilitate the authors mappingFor more details on the authors helper see Script-provided authors mapping article.