Fix base query for empty diff

When the latest branch cut is from the very same hash as the previous
branch was cut from, then the rev-list gives an empty list. Originally
the last item from the list should have been taken. Since the list is
empty the splitlines()[-1] gives "IndexError: list index out of range".
This patch fixes this case with returning None early.

Change-Id: If5ea4a356b0c7620e2de1d2ab77951d8b76bb5e2
This commit is contained in:
Előd Illés 2022-09-30 20:13:15 +02:00
parent f1dda04b63
commit bc990ff880

View File

@ -445,6 +445,10 @@ def get_branch_base(workdir, repo, branch):
LOG.warning('failed to retrieve branch base: %s [%s]',
e, e.output.strip())
return None
if parents == '':
LOG.warning('branch base query result was empty for %s repository',
repo)
return None
parent = parents.splitlines()[-1]
# Now get the ^^! commit
cmd = [