From 6412cf1c8735db0e012d6adea93fea1acbaf4f5a Mon Sep 17 00:00:00 2001 From: Oliver Walters <oliver.henry.walters@gmail.com> Date: Wed, 7 Apr 2021 20:55:44 +1000 Subject: [PATCH] Hide git information if there is an error --- InvenTree/InvenTree/version.py | 4 ++-- InvenTree/templates/about.html | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index 4d3d546789..d7bcd4f7ed 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -37,7 +37,7 @@ def inventreeCommitHash(): try: return str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip() - except FileNotFoundError: + except: return None @@ -47,5 +47,5 @@ def inventreeCommitDate(): try: d = str(subprocess.check_output('git show -s --format=%ci'.split()), 'utf-8').strip() return d.split(' ')[0] - except FileNotFoundError: + except: return None diff --git a/InvenTree/templates/about.html b/InvenTree/templates/about.html index cedfb40ca1..3305df430f 100644 --- a/InvenTree/templates/about.html +++ b/InvenTree/templates/about.html @@ -25,14 +25,20 @@ <td><span class='fas fa-hashtag'></span></td> <td>{% trans "Django Version" %}</td><td><a href="https://www.djangoproject.com/">{% django_version %}</a></td> </tr> + {% inventree_commit_hash as hash %} + {% if hash %} <tr> <td><span class='fas fa-code-branch'></span></td> - <td>{% trans "Commit Hash" %}</td><td><a href="https://github.com/inventree/InvenTree/commit/{% inventree_commit_hash %}">{% inventree_commit_hash %}</a></td> + <td>{% trans "Commit Hash" %}</td><td>{{ hash }}</td> </tr> + {% endif %} + {% inventree_commit_date as commit_date %} + {% if commit_date %} <tr> <td><span class='fas fa-calendar-alt'></span></td> - <td>{% trans "Commit Date" %}</td><td>{% inventree_commit_date %}</td> + <td>{% trans "Commit Date" %}</td><td>{{ commit_date }}</td> </tr> + {% endif %} <tr> <td><span class='fas fa-book'></span></td> <td>{% trans "InvenTree Documentation" %}</td>