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
This commit is contained in:
parent
cbc7f627ca
commit
b8a7792977
|
@ -95,8 +95,12 @@ class Repo(object):
|
|||
continue
|
||||
repo.create_head(ref.remote_head, ref, force=True)
|
||||
|
||||
# Reset to remote HEAD (usually origin/master)
|
||||
repo.head.reference = origin.refs['HEAD']
|
||||
# try reset to remote HEAD (usually origin/master)
|
||||
# If it fails, pick the first reference
|
||||
try:
|
||||
repo.head.reference = origin.refs['HEAD']
|
||||
except IndexError:
|
||||
repo.head.reference = origin.refs[0]
|
||||
reset_repo_to_head(repo)
|
||||
repo.git.clean('-x', '-f', '-d')
|
||||
|
||||
|
|
Loading…
Reference in New Issue