Gerrit integration for sync/submit? #853
Replies: 2 comments 1 reply
-
Some implementation notes that I think might be useful for implementing the syncing feature: you can query for the latest (and previous) patchsets of a change by using
Although you have to know the "change number" that gerrit picked for the CL. (I believe that is just an incrementing number as CLs are created). The "shard bucket" thing there is just a repeat of the last 2 digits of that number. One way to look up the "change number" with just the
Although that's admittedly made easier by the fact that fuchsia's gerrit is a public instance; if you needed to authenticate that would be a bit harder. |
Beta Was this translation helpful? Give feedback.
-
I started support for customizable Git hosting providers ("forges"). For example, you can see the Phabricator work in progress here: #866. You could add a Gerrit forge with your implementation. Phabricator uses a de-facto change ID via the
It might be easiest to do
Phabricator has a dedicated command to check out the newest version of each CL ( |
Beta Was this translation helpful? Give feedback.
-
Gerrit is a code review system serving a similar role as GitHub Pull Requests, but the workflow is different.
Gerrit asks you to install a commit hook which adds a
Change-Id:
footer (picked randomly for new commits) to each commit. Then any commit you upload viagit push gerrit SOME_COMMIT:refs/for/main
gets uploaded as a seperate "change list" (CL) in the gerrit UI. Uploading a new commit with the sameChange-Id
overwrites the existing one by creating a new "patchset" (numbered by the number of times the CL has been uploaded).If you push a branch with multiple commits, they each get uploaded as a chain of dependent CLs.
This already works really well with the
git-branchless
model, since handles dependent CLs in a very similar way as git-branchless, and git-branchless can help automate restacking after editing a commit higher in the chain.I still think the integration could be improved in a couple of major ways:
git branchless submit
should be able to do thegit push
torefs/for/main
(or whatever the desired branch is called) for all relevant commitsThe should be some way of downloading updated patch sets from gerrit if a CL was updated on another computer or by another collaborator. As an example, I've been using managing a chain of commits with git-branchless, and had uploaded patchset 4 of https://fxrev.dev/797262 . David Koloski then helped me out by fixing some stuff in the CL that needs to be done before it can be submitted, and uploaded patchsets 5 and 6. In order to rebase the stack, I had to do some manual steps to
git fetch https://fuchsia.googlesource.com/fuchsia refs/changes/62/797262/6
, unhide FETCH_HEAD, restack the later commits on top of this new FETCH_HEAD, then hide the original commit that had been uploaded as patchset 4. It would be nice if there were a way to manually mark that commit as a successor to the original commit (the way amend does), and it would be even better if there were a way to automatically fetch the newest version of each CL automatically (perhaps withgit branchless sync
)Caveat: this explanation of "how gerrit works" is mostly informed by my experience contributing to the Fuchsia project. This really is how gerrit works on the Fuchsia project, but I believe it's possible to configure gerrit to work slightly differently; I think you can make the
Change-Id
footer optional rather than mandatory, for example. And it's possible to enable something called "topics" which make it possible for multiple commits to land together rather than each getting its own review and landing separately. So to be perfect it might need to be more tunable than just fit this specific workflow, although I think just handling this configuration might be a good place to start.Beta Was this translation helpful? Give feedback.
All reactions