问题
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