Repository sync setup¶
These are the ways we may setup git repository sync between Gerrit and other code hosting platforms.
Bidirectional sync¶
Bidirectional sync is used in early adoption stages when Gerrit has not yet become the ultimate source of truth for the repository.
New commits are synced for selected branches - only if fast-forward merge is possible. If fast-forward is not possible synchronization is aborted and human intervention is required. Git tags are not synced.
This allows to merge changes in both locations (e.g. in Gerrit and in Forgejo). If merges happen in both locations in rapid succession (simultaneously) human intervention will be required to decide which side to rebase and force push.
Bidirectional sync is defined in this Jenkins pipeline and is performed by this script. The list of repositories and branches being synced by this job is defined in this file.
Adding new branch for bidirectional sync¶
New branches for bidirectional sync must be added manually. This procedure is
most likely to be relevant for new support/vM.NN
branches:
- Make sure that branch exists in both git repositories (i.e in Forgejo and in Gerrit). You may need to contact repository owner or instance administrator if you don't have sufficient permissions.
- If you're branching off of an existing branch you may skip creating new branch in Gerrit and rely on the sync job to do it instead.
- Add new branch name to the list of synced branches.
Mirror¶
Unidirectional sync strategy is used when Gerrit is the source of truth for git repository.
Git commits, branches and tags may be added only in Gerrit. All changes made
in mirror repositories will be lost after the next push.
This sync strategy uses
git push --mirror
under the hood.