简体   繁体   English

使用Subversion存储库的Git镜像设置Gerrit

[英]Setting up Gerrit with a Git mirror of a Subversion repository

At work, we currently use Subversion for SCM. 在工作中,我们目前使用Subversion for SCM。 I have set up a local git-svn mirror and use that as my primary development workspace. 我已经设置了一个本地git-svn镜像,并将其用作我的主要开发工作区。 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. 团队中的另一个开发人员也想迁移到Git,因此我们正在考虑使用svn存储库的git镜像。 I would also like to try Gerrit alongside this exercise. 我还想和Gerrit一起尝试这个练习。

The setup I imagine is something along these lines: 我想象的设置是这样的:

  1. A git mirror for the svn repository. svn存储库的git镜像。 The master branch on this is in sync with the trunk on svn. 这上的主分支与svn上的主干同步。

  2. For each feature a topic branch is created. 对于每个要素,都会创建主题分支。 This is tied to Gerrit, on which the review happens. 这与审查发生的Gerrit有关。 Once the changeset is approved, Gerrit merges the topic branch back master. 一旦变更集获得批准,Gerrit就会合并主题分支返回主变量。

  3. A gitweb, or similar, web application to view the repository on the browser. gitweb或类似的Web应用程序,用于在浏览器上查看存储库。

  4. A similar process for other branches on subversion besides trunk. 除了trunk之外,其他分支在subversion上的类似过程。

Essentially, what I want is that I interact only with my local git clone and the Gerrit webapp; 基本上,我想要的是我只与我的本地git clone和Gerrit webapp交互; pushing the reviewed changes back to svn should happen automatically. 将审查的更改推回到svn应该会自动发生。 How do I go about setting up something like this? 我如何设置这样的东西?

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 在Gerrit服务器上设置你的git clone
  2. Create an svn hook or a periodic task which will fetch from svn and push to your git clone 创建一个svn钩子或一个周期性任务,它将从svn中获取并推送到你的git clone
  3. Gerrit has a built-in version of gitweb, so you are covered there Gerrit有一个内置版本的gitweb,所以你可以在那里看到它
  4. On the Gerrit server, create a change merged hook which will push back to svn 在Gerrit服务器上,创建一个更改合并钩子 ,它将推回到svn

Like Greg mentioned above, when step 4 fails things will be tricky. 就像上面提到的Greg一样,当第4步失败时,事情就会变得棘手。 You'll have to reset the git repository in Gerrit to match svn and re-submit your change. 您必须重置Gerrit中的git存储库以匹配svn并重新提交您的更改。 This will be much easier if/when you convince the rest of your team to drop svn and use git/Gerrit :-) 如果/当你说服你的团队的其他人放弃svn并使用git / Gerrit时,这会更容易:-)

Good Luck! 祝好运!

It's possible to setup a Git mirror that be in sync with the repository SVN 可以设置与存储库SVN同步的Git镜像

Install SubGit into your SVN repository: SubGit安装到SVN存储库中:

$ 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. 然后使用Apache或其他任何设置访问创建的链接Git存储库(path / to / svn / repository / .git)。 Every push to that Git repository will be translated to an SVN revision and vice versa. 对Git存储库的每次推送都将转换为SVN版本,反之亦然。

So you may use the linked Git repository in Gerrit and for you team (as if SVN never existed). 因此,您可以在Gerrit和团队中使用链接的Git存储库(就好像SVN从未存在过)。 After that you may shutdown SVN repository (or continue using). 之后,您可以关闭SVN存储库(或继续使用)。 To stop synchronization before shutting down run: 在关闭运行之前停止同步:

$ subgit uninstall path/to/svn/repository

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM