[templates] Add version and commit to footer

This commit is contained in:
2026-03-11 16:26:51 -04:00
parent 4036e883fd
commit a343e2f3fa
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,31 @@
import subprocess
from pathlib import Path
def version_info(request):
PROJECT_ROOT = Path(__file__).resolve().parent.parent
try:
commit = (
subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"],
cwd=PROJECT_ROOT,
stderr=subprocess.DEVNULL,
)
.decode("utf-8")
.strip()
)
except (subprocess.SubprocessError, FileNotFoundError):
commit = "unknown"
try:
pyproject = PROJECT_ROOT / "pyproject.toml"
version = "unknown"
if pyproject.exists():
for line in pyproject.read_text().splitlines():
if line.startswith("version = "):
version = line.split("=")[1].strip().strip('"')
break
except Exception:
version = "unknown"
return {"app_version": version, "git_commit": commit}

View File

@ -183,6 +183,7 @@ TEMPLATES = [
"videos.context_processors.video_lists",
"music.context_processors.music_lists",
"scrobbles.context_processors.now_playing",
"vrobbler.context_processors.version_info",
],
},
},

View File

@ -268,5 +268,9 @@
})()
</script>
<footer class="mt-4 py-2 text-center text-muted border-top">
<small>v{{ app_version }} ({{ git_commit }})</small>
</footer>
</body>
</html>