How to find the Git Revision Hash in a synced SVN repo using SubGit?

321 views Asked by At

In the process of moving from SVN to git, we're evaluating the SVN Mirror Stash plugin (SubGit) in Stash.

One of our requirements is that the git revision hash be available in the SVN repo, either in a custom revprop, or through a JSON formatted log message.

Essentially I'm trying to do the reverse of what is described in this question.

I control both the git repo and the svn repo, and I'm happy to write a custom hook / script, but I haven't been able to find the appropriate place to insert this hook, either in the subgit or stash documentation. I'm also very interested in the best practice to insert such functionality.

1

There are 1 answers

0
vadishev On BEST ANSWER

Just a short summary after discussing this problem between @Brilliantnut and [email protected]:

Our team has decided to support special kind of revision properties that keep metadata information of corresponding Git commit: author, committer, timestamp, commit ID, etc.

I'll update this answer as soon as we publish new build with this feature implemented.

Update:

In order to set Git specific revision properties in Subversion repository, adjust SubGit configuration file as follows:

$ edit GIT_REPO/subgit/config

[svn]
    ...
    revisionProperties = committer, author, date, log, commit
    ...

and then run subgit install in order to activate this configuration update:

$ subgit install GIT_REPO

After that SubGit sets the following properties for every revision it converts from Git to SVN:

subgit:committer="Git Committer <[email protected]>"
subgit:author="Git Author <[email protected]>"
subgit:date="2015-06-10 16:46:01 +0400"
subgit:log="fix foo"
subgit:commit=9039c430e12d25c3ef250c8e49c4a57877c36343

You can also choose which properties to set by adjusting configuration option:

[svn]
    ...
    revisionProperties = date, log, commit
    ...

There are the following limitations for this feature:

  1. subgit:* revision properties are not set on those revisions that were committed by SVN users and not converted from Git commits by SubGit;

  2. If one adds/removes new Git branch or tag on a commit which is already synchronized with SVN repository, SubGit creates a new SVN revision which has no subgit:* properties set.