Wait for a commit to appear in the repo.

This fixes a potential race condition where a change may be reported
as merged in gerrit, but due to replication, the commit may not
yet show up in the repo.  If a job is started during this time frame,
then the git repo will not be in the expected state for testing.

This now waits for the commit associated with the latest patchset
for the change to become the commit at ref/heads/branch.  This
check obviously only works to verify that the merged commit is the
_most recently_ merged commit (ie, it does not perform the more
general check that the commit was merged at some time in the past).
That's okay here because zuul's merge commands are issued
synchronously from a single thread, so if zuul instructs gerrit
to merge a change, it should become that head, and no other changes
should be able to merge during that time.

Change-Id: I2213916c4850e7be80795cbed2dac29eacdb82bf
Reviewed-on: https://review.openstack.org/10673
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
3 files changed