At my place of work, we use a Gerrit server for code review. Often times different people will author commits that are unrelated. I've run into an issue where I must author a commit which depends on two other, unrelated commits.
Let's say there are two commits on a gerrit server:
These two are independent of each other. My job is to implement Commit C: "Added function flipRotateImage". This requires both commits A and B to be present.
I have two questions:
A Gerrit URL refers to a single change on a single branch, so if your change depends on multiple changes, or the same change on multiple branches of a project, you will need to explicitly list each URL. Simply add another “Depends-On:” line to the footer for each additional change.
You can, however, also add another commit on top of your existing commit in Gerrit, which will create a second change (and thus another review) that is based on your first change. Gerrit will show the relationship between these two changes as a so-called relation chain.
In some cases, it is possible to resolve merge conflicts issues in Gerrit using simple rebase triggered directly from the Gerrit UI. Just click on "Rebase" button to rebase the change. The behaviour is described in Gerrit Review UI: If the rebase is successful, a new patch set with the rebased commit is created.
While you resolve conflicts that arise from a git merge for GitHub, you will need to use git rebase with your change on Gerrit. After resolving locally, with GitHub, you end up with another commit on your pull request branch and push it to the server, which should then allow you to finish merging the change.
git rebase --onto
. The exact procedure would depend slightly on how you choose to deal with the problem in the first question, but ignoring that and assuming you have checked out the topic branch for C then git rebase --onto newA oldA
will do.A change has been proposed in Gerrit to support this kind of dependency specification outside of the git DAG. The change is intended for cross-project dependencies, but it should also support this kind of intra-project commit dependency as well. Sorry it doesn't help you now, though.
https://gerrit-review.googlesource.com/#/c/55243
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With