add error handling to git_head

master
Aevann 2023-01-23 02:54:37 +02:00
parent 6fb5f7e552
commit 705f04b556
1 changed files with 5 additions and 2 deletions

View File

@ -90,8 +90,11 @@ def git_head():
with open('.git/HEAD', encoding='utf_8') as head_f:
head_txt = head_f.read()
head_path = git_regex.match(head_txt).group(1)
with open('.git/' + head_path, encoding='utf_8') as ref_f:
gitref = ref_f.read()[:7]
try:
with open('.git/' + head_path, encoding='utf_8') as ref_f:
gitref = ref_f.read()[:7]
except:
gitref = 'Error'
return (gitref, head_txt)
@app.context_processor