catch error if git repo can't be accessd

This commit is contained in:
helgeerbe 2023-08-10 10:53:33 +02:00
parent 40c720aa57
commit 9475a78211

View File

@ -18,9 +18,13 @@ from dulwich import porcelain
def get_firmware_specifier_build_flag(): def get_firmware_specifier_build_flag():
try: try:
build_version = porcelain.describe('.') # '.' refers to the repository root dir build_version = porcelain.describe('.') # '.' refers to the repository root dir
branch_name = porcelain.active_branch('.').decode('utf-8') except Exception as err:
except: print(f"Unexpected {err=}, {type(err)=}")
build_version = "g0000000" build_version = "g0000000"
try:
branch_name = porcelain.active_branch('.').decode('utf-8') # '.' refers to the repository root dir
except Exception as err:
print(f"Unexpected {err=}, {type(err)=}")
branch_name = "" branch_name = ""
build_flag = "-D AUTO_GIT_HASH=\\\"" + build_version + "\\\" " build_flag = "-D AUTO_GIT_HASH=\\\"" + build_version + "\\\" "
build_flag += "-D AUTO_GIT_BRANCH=\\\"" + branch_name + "\\\"" build_flag += "-D AUTO_GIT_BRANCH=\\\"" + branch_name + "\\\""