A collection of scripts to help synchronizing a git server with an existing subversion repository
Find a file
2018-02-02 21:47:12 -08:00
install Fix my brain not working right 2014-11-11 18:23:52 -08:00
sync-client-hooks Initial commit with the scripts to synchronize git with svn 2012-05-30 11:58:42 +02:00
.gitattributes Enforce unix line endings 2014-11-12 14:40:41 -08:00
git-mirror-to-svn.sh Remove --allow-empty option from cherry-pick 2014-11-12 14:58:28 -08:00
git-sync-with-svn.sh Allow using a remote git repo and don't assume the svn is write-protected 2014-11-11 18:03:38 -08:00
github-svn-mirror.sh Fix silly syntax error 2018-02-02 21:47:12 -08:00
README.markdown Initial commit with the scripts to synchronize git with svn 2012-05-30 11:58:42 +02:00
report-error.sh Initial commit with the scripts to synchronize git with svn 2012-05-30 11:58:42 +02:00

git SVN Sync

This repository is intended to provide synchronization between a running SVN repository and git, so that we can get away from subversion while the build jobs are ported.

Workflow

The idea is to use pure git exclusively. The subversion repository is up to date and used to build artifacts and jars, but nobody is expected to write to it except the git sync client.

Therefore git would be used both at client and server side. This is an improvement over using git-svn because it allows to commit branches to the server, and avoids rewriting history when commiting to svn, among other things.

Technical view

For every project in subversion, two git repositories are created, the server and the sync client.

git Server

It is a normal bare repository, which supports every git operation. Every developer clones this repository and uses it exclusively for the project.

When someone pushes changes to the master branch, a hook is run which uses the sync client to bring the changes to subversion.

git Sync client

This is a repository which is a clone of the git server. When the post-receive hook at the server is activated, the following happens at this client:

  • Changes are pulled from the server to the master branch.
  • The master branch is merged into a svn sync branch.
  • The changes are sent to subversion via git-svn.

This repository is not intended for developers to use. It rejects every push and commit, and should only automatically sync with the server.

Maintaining consistency

The git server and subversion should be in the same state at every time. To guarantee this, the following conditions are required:

  • Only the git sync client should ever send changes to subversion. The write access to svn should be restricted to the remote git user.
  • Nobody except the build jobs in jenkins uses subversion directly anymore. Developers interact only with the git server.
  • The git sync client is never modified. It only pulls changes from the git server (only fast-forward allowed).

The consistency is assured via hooks that are installed at the server and sync client. Access to subversion has to be configured separately.

Reporting

If something does not work correctly, a mail will be sent specifying the project which had the problem and the registered error

Setup

Initial setup

The machine where the repositories are installed needs the following environment variables (defined in its ~/.bashrc):

  • GIT_SCRIPTS: directory where the git sync scripts are located
  • GIT_BASE: directory where the git repositories are stored.
  • GIT_SVN_SYNC_BASE: directory where the sync repositories are stored.
  • GIT_SVN_SYNC_BRANCH: name of the branch that is synchronized with subversion.

This repository should be cloned in the directory GIT_SCRIPTS.

SVN User

Git needs to have write access to subversion.

Git config

For the git user that will sync with svn

git config --global user.email "the@email"
git config --global user.name "Git User"

New project

Each project in subversion can be initialized with the install/git-repository-from-svn.sh script. It makes sure that the initial setup is carried and that the hooks are activated.