Use the git commit hash as the app version
- Spec header, status pill and footer now document '<env> @ <hash>' instead of invented release numbers - Backend settings expose GIT_COMMIT_HASH / APP_ENV / APP_VERSION, mirroring the original app - Frontend bakes the short hash in at build time and shows it in the top bar
This commit is contained in:
@@ -3,6 +3,7 @@ Django settings for the J621 backend.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
@@ -19,6 +20,24 @@ ALLOWED_HOSTS = [
|
||||
if host.strip()
|
||||
]
|
||||
|
||||
|
||||
def _git_commit_hash():
|
||||
"""Short git hash of the running build, mirroring the original app."""
|
||||
try:
|
||||
return subprocess.check_output(
|
||||
["git", "rev-parse", "--short", "HEAD"],
|
||||
cwd=BASE_DIR,
|
||||
text=True,
|
||||
stderr=subprocess.DEVNULL,
|
||||
).strip()
|
||||
except (subprocess.SubprocessError, OSError):
|
||||
return "unknown"
|
||||
|
||||
|
||||
GIT_COMMIT_HASH = _git_commit_hash()
|
||||
APP_ENV = "dev" if DEBUG else "prod"
|
||||
APP_VERSION = f"{APP_ENV} @ {GIT_COMMIT_HASH}"
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
|
||||
Reference in New Issue
Block a user