From 705f04b556012293ea7feb49526972c851fd4a80 Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 23 Jan 2023 02:54:37 +0200 Subject: [PATCH] add error handling to git_head --- files/routes/jinja2.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index de53b8a2d..101673dca 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -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