From d7a8bb6d33cb20744d733ba0f63cf146cb355e4d Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Wed, 12 Apr 2023 22:12:27 +0200 Subject: [PATCH] fix git hash --- acros/management/commands/clearcache.py | 7 +++++++ acros/templatetags/version.py | 4 +++- deploy.sh | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 acros/management/commands/clearcache.py diff --git a/acros/management/commands/clearcache.py b/acros/management/commands/clearcache.py new file mode 100644 index 0000000..f052cb6 --- /dev/null +++ b/acros/management/commands/clearcache.py @@ -0,0 +1,7 @@ +from django.core.cache import cache +from django.core.management.base import BaseCommand + + +class Command(BaseCommand): + def handle(self, *args, **kwargs): + cache.clear() diff --git a/acros/templatetags/version.py b/acros/templatetags/version.py index a35fb21..91462b6 100644 --- a/acros/templatetags/version.py +++ b/acros/templatetags/version.py @@ -1,3 +1,4 @@ +from pathlib import Path from subprocess import run from django import template @@ -8,9 +9,10 @@ register = template.Library() @register.simple_tag def commit_id(): + current_dir = Path(__file__).parent commit = cache.get("commit") if not commit: - sp = run(["git", "rev-parse", "--verify", "HEAD"], capture_output=True) + sp = run(["git", "rev-parse", "--verify", "HEAD"], capture_output=True, cwd=current_dir) commit = sp.stdout.decode().strip() cache.set("commit", commit) return commit diff --git a/deploy.sh b/deploy.sh index 2820ea3..10fa9d6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -11,5 +11,6 @@ git pull $manage scss $manage collectstatic --noinput $manage migrate +$manage clearcache sudo systemctl reload acronomy.service