Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up Gerrit with a Git mirror of a Subversion repository

Tags:

git

svn

gerrit

At work, we currently use Subversion for SCM. I have set up a local git-svn mirror and use that as my primary development workspace. I am comfortable with the basic functionality now. One other developer in the team also wants to move to Git, so we are considering using a git mirror of the svn repository. I would also like to try Gerrit alongside this exercise.

The setup I imagine is something along these lines:

  1. A git mirror for the svn repository. The master branch on this is in sync with the trunk on svn.

  2. For each feature a topic branch is created. This is tied to Gerrit, on which the review happens. Once the changeset is approved, Gerrit merges the topic branch back master.

  3. A gitweb, or similar, web application to view the repository on the browser.

  4. A similar process for other branches on subversion besides trunk.

Essentially, what I want is that I interact only with my local git clone and the Gerrit webapp; pushing the reviewed changes back to svn should happen automatically. How do I go about setting up something like this?

like image 896
Binil Thomas Avatar asked Oct 15 '11 19:10

Binil Thomas


People also ask

How do I mirror a git repository?

Navigate to the repository you just cloned. Pull in the repository's Git Large File Storage objects. Mirror-push to the new repository. Push the repository's Git Large File Storage objects to your mirror.

Can you use Git and SVN together?

git-svn is a specialized tool for Git users to interact with Git repositories. It works by providing a Git frontend to an SVN backend. With git-svn, you use Git commands on the local repository, so it's just like using normal Git. However, behind the scenes, the relevant SVN commands are sent to the server.

How do I clone a Subversion repository?

You can clone from a SVN repo using the git svn clone command. -s = If your SVN repo follows standard naming convention where main source is in “trunk”, branches are created in “branches”. Here we are telling git svn that trunk is the “trunk” directory, maintenance is the “branches” directory etc.


2 Answers

Unfortunately it isn't possible to do this all automatically (at least, not without a lot of work). Here are some steps which can get you close:

  1. Set up your git clone on the Gerrit server
  2. Create an svn hook or a periodic task which will fetch from svn and push to your git clone
  3. Gerrit has a built-in version of gitweb, so you are covered there
  4. On the Gerrit server, create a change merged hook which will push back to svn

Like Greg mentioned above, when step 4 fails things will be tricky. You'll have to reset the git repository in Gerrit to match svn and re-submit your change. This will be much easier if/when you convince the rest of your team to drop svn and use git/Gerrit :-)

Good Luck!

like image 95
Brad Avatar answered Oct 17 '22 10:10

Brad


It's possible to setup a Git mirror that be in sync with the repository SVN

Install SubGit into your SVN repository:

$ subgit install path/to/svn/repository

Then just setup access to the linked Git repository created (path/to/svn/repository/.git) using Apache or whatever. Every push to that Git repository will be translated to an SVN revision and vice versa.

So you may use the linked Git repository in Gerrit and for you team (as if SVN never existed). After that you may shutdown SVN repository (or continue using). To stop synchronization before shutting down run:

$ subgit uninstall path/to/svn/repository
like image 2
Dmitry Pavlenko Avatar answered Oct 17 '22 10:10

Dmitry Pavlenko