Wrap inventreeBranch check in try/except (#5842)

- Same as in master branch
This commit is contained in:
Oliver 2023-11-03 11:35:21 +11:00 committed by GitHub
parent d2a313bda9
commit 5d55555394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,8 +162,11 @@ def inventreeBranch():
if main_commit is None:
return None
branch = main_repo.refs.follow(b'HEAD')[0][1].decode()
return branch.removeprefix('refs/heads/')
try:
branch = main_repo.refs.follow(b'HEAD')[0][1].decode()
return branch.removeprefix('refs/heads/')
except IndexError:
return None # pragma: no cover
def inventreeTarget():