Search code examples
gitgerrit

What if I push twice to gerrit and the reviewer tries to merge the last one


I've worked with Gerrit for a while and known the basic workflow of Gerrit. enter image description here

Up to now, everything is OK: When I finish my coding job, I push my codes to Gerrit, then Jenkins and my leader start to work. If my leader(reviewer) +2 for my codes and Jenkins finishes its job without any error, my codes will be merged to the branch mater. This is quite clear and simple.

But, what if I push my changes twice in a very short period? Let's say I pushed A and then I pushed B. Both of them trigger Jenkins to do its jobs. At the same time, for some reason, my leader(reviewer) didn't review A but he reviewed B immediately. Then he +2 for B. Meaning that, A haven't been merged to the branch master but my leader is trying to merge B to the branch master. BUT, A is the parent of B. Obviously, logically, merging A must happen before merging B.

I want to know what Gerrit will do for this case. Will it generate an error to hint the reviewer to review the previous push?


Solution

  • If B is dependent on A and A is not ready to be submitted, B is blocked. The submit button on B page is disabled.

    If you want to submit B anyway, you need to rebase B first so that it gets independent from A. The rebase could fail due to conflicts.