Is two way sync between gerrit and github.com possible?

人走茶凉 提交于 2019-12-22 22:47:50

问题


For a project exisitng in github.com private repository, I am setting up gerrit code review.

I am using the gerrit's replication plugin to keep the gerrit repository in sync with github.com.

But if someone commits (say commit-a) and pushes directly to github.com, the commit-a is overwritten in github.com, when gerrit does the replication process (because, it replicates only the things in gerrit mirror).

But I want to implement a 2-way sync. Something like, whenever a push is made to gerrit, it has to check github.com and update its mirror with new code from there and then to continue the merge.

Is that possible?


回答1:


This is a hard problem. Multi-master setups like what you describe exist in many places, but rely on the involved systems to be heavily integrated and built to support this.

I see two options:

  • Both Gerrit and Github would have to be capable of talking to each other and allow the git on server A to be locked while server B updates its ref. Once B has been updated, the data is replicated to A, and A is unlocked. This feature does not exist and probably never will.
  • The server receiving a push could be optimistic and hope that a concurrent update won't happen. For a moderately busy server this won't happen most of the time, but if it does happen there must be a sane recovery strategy. Recovery becomes much more difficult if not impossible if the concurrency check is done asynchronously, i.e. if e.g. Gerrit signals "okay" on the push before actually securing the transaction with Github first. Synchronous updates would solve this but would be detrimental to performance and reliability.



回答2:


It might not be the direct answer to your question, but if you would make Gerrit your source of truth and you only care about pull requests, you can use the github plugin to import the PR into a Gerrit change.

This wouldn't help, of course, if anybody pushes commits directly to Github.

In general, I agree with Magnus Bäck.



来源:https://stackoverflow.com/questions/21424563/is-two-way-sync-between-gerrit-and-github-com-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!