From f1ca92d84673a2116aba2f4c7a897057bc772e7c Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Wed, 12 Jan 2022 20:24:10 +0100 Subject: [PATCH] Fetch Git commit (and tag, if exists), with its date --- config/settings.py | 1 + templates/ultron/dashboard/dashboard.html | 2 +- ultron/core/context_processors.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 ultron/core/context_processors.py diff --git a/config/settings.py b/config/settings.py index 737836c688..80534cac0b 100644 --- a/config/settings.py +++ b/config/settings.py @@ -78,6 +78,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + "ultron.core.context_processors.git_describe" ], }, }, diff --git a/templates/ultron/dashboard/dashboard.html b/templates/ultron/dashboard/dashboard.html index e4bacfede7..57f5853a33 100644 --- a/templates/ultron/dashboard/dashboard.html +++ b/templates/ultron/dashboard/dashboard.html @@ -11,7 +11,7 @@

Hi {{ user.username }} !

- Welcome to Ultron v0.42 (last update : 9-1-2022)
+ Welcome to Ultron {{ git_describe }} (last update : {{ git_date }})
This application is there to help us manage the gymnasts (evolution, evaluation, routine, scores, ...). It is not perfect so feel free to make improvement proposals, bug reports, … by sending me an email.

Gelukkig nieuwjaar 2022 en mijn beste wensen! diff --git a/ultron/core/context_processors.py b/ultron/core/context_processors.py new file mode 100644 index 0000000000..355654d6a1 --- /dev/null +++ b/ultron/core/context_processors.py @@ -0,0 +1,12 @@ +import subprocess + + +def git_describe(request) -> str: + return { + "git_describe": subprocess.check_output( + ["git", "describe", "--always"] + ).decode(), + "git_date": subprocess.check_output( + ["git", "show", "-s", r"--format=%cd", r"--date=format:%d-%m-%Y"] + ).decode(), + }