Add retry on git push failure

This adds retry if target is old default branch. This may happen only if
user didn't fetch remote for extended period of time and old default
branch no longer exists.

R=ehmaldonado@chromium.org

Change-Id: I81981049ee006f68a073718180b454c230d055e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2473757
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/gerrit_util.py b/gerrit_util.py
index d91312a..aa8a396 100644
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -926,6 +926,12 @@
   raise GerritError(200, 'Unable to get gerrit branch')
 
 
+def GetProjectHead(host, project):
+  conn = CreateHttpConn(host,
+                        '/projects/%s/HEAD' % urllib.parse.quote(project, ''))
+  return ReadHttpJsonResponse(conn, accept_statuses=[200])
+
+
 def GetAccountDetails(host, account_id='self'):
   """Returns details of the account.