Handle non-valid HEAD
Handle non-valid HEAD

Repo might have HEAD that points on master branch while
in reality it doesn't exists.

This fix will choose first reference in case origin/HEAD
doesn't exist.

Change-Id: I22fec070af4445c1cb3dd34e9c3b7f10e349bd0f

gooddata/zuul,wikimedia/integration-zuul,gooddata/zuul,wikimedia/integration-zuul,wikimedia/integration-zuul,gooddata/zuul,gooddata/zuul,wikimedia/integration-zuul,gooddata/zuul