Skip to content

Commit 7e6623d

Browse files
committed
Show the deployed version in the footer, linked to the changelog
1 parent 649dc02 commit 7e6623d

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ This page tries to contain all use facing changes made on DocHub.
44

55
# Unreleased
66

7+
* Show the deployed version in the footer, linked to the changelog
8+
79
# 2026.5.3
810

11+
*No user facing changes*
12+
913
# 2026.5.2
1014

1115
* Add a /stats/ page with charts of DocHub activity over time

www/context_processors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ def sentry(context):
1010
"SENTRY_DSN": getattr(settings, "SENTRY_DSN", None),
1111
"SENTRY_RELEASE": getattr(settings, "SENTRY_RELEASE", None),
1212
}
13+
14+
15+
def version(context):
16+
return {"GIT_DESCRIBE": getattr(settings, "GIT_DESCRIBE", None)}

www/settings.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import subprocess
23
from pathlib import Path
34

45
import environ
@@ -89,6 +90,7 @@
8990
"django.contrib.messages.context_processors.messages",
9091
"www.context_processors.read_only",
9192
"www.context_processors.sentry",
93+
"www.context_processors.version",
9294
],
9395
},
9496
},
@@ -155,6 +157,24 @@
155157
SENTRY_DSN = env("SENTRY_DSN", default=None)
156158
SENTRY_RELEASE = get_default_release()
157159

160+
161+
def _git_describe() -> str | None:
162+
try:
163+
result = subprocess.run(
164+
["git", "describe", "--tags", "--dirty", "--always"],
165+
cwd=BASE_DIR,
166+
capture_output=True,
167+
text=True,
168+
timeout=2,
169+
check=True,
170+
)
171+
except (subprocess.SubprocessError, FileNotFoundError):
172+
return None
173+
return result.stdout.strip() or None
174+
175+
176+
GIT_DESCRIBE = _git_describe()
177+
158178
FILE_STORAGE = "django.core.files.storage.FileSystemStorage"
159179

160180
# Only configure S3 storage if we have a STORAGE_ENDPOINT env variable else, default to the local filesystem

www/templates/base.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,14 @@
251251
<span class="text-muted mx-1">&bull;</span>
252252
<a href="{% url 'stats' %}">Stats</a>
253253
{% endif %}
254+
{% if GIT_DESCRIBE %}
255+
<span class="text-muted mx-1">&bull;</span>
256+
<a href="https://github.com/UrLab/dochub/blob/main/CHANGELOG.md"
257+
class="text-muted text-decoration-none"
258+
title="Version déployée — voir le changelog">
259+
<small>{{ GIT_DESCRIBE }}</small>
260+
</a>
261+
{% endif %}
254262
</div>
255263
</footer>
256264
{% endblock fullpage %}

0 commit comments

Comments
 (0)