feat: version dynamique via fichier VERSION
- Fichier VERSION à la racine (4.0.3) - _get_app_version() avec cache dans dashboard.py - Lecture depuis VERSION (dev) ou /app/VERSION (Docker) - Fallback '0.0.0' si fichier absent - board.py: import _get_app_version depuis dashboard - Les deux _sidebar_data() remplacent '4.0.3' par _get_app_version() - Déploiement: changer VERSION → mettre à jour sans toucher le code - 143 tests passent
This commit is contained in:
@@ -10,6 +10,7 @@ from fastapi.responses import HTMLResponse, JSONResponse
|
|||||||
from app.db import get_conn
|
from app.db import get_conn
|
||||||
from app.services.gitea_client import gitea
|
from app.services.gitea_client import gitea
|
||||||
from app.auth.session import SessionManager
|
from app.auth.session import SessionManager
|
||||||
|
from app.routers.dashboard import _get_app_version
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
router = APIRouter(tags=["board"], prefix="/board")
|
router = APIRouter(tags=["board"], prefix="/board")
|
||||||
@@ -397,7 +398,7 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict:
|
|||||||
"gitea_linked": gitea_linked,
|
"gitea_linked": gitea_linked,
|
||||||
"github_linked": github_linked,
|
"github_linked": github_linked,
|
||||||
"has_active_workspace": has_active_workspace,
|
"has_active_workspace": has_active_workspace,
|
||||||
"app_version": "4.0.3",
|
"app_version": _get_app_version(),
|
||||||
"local_workspaces": _local_workspaces_for_user(user)}
|
"local_workspaces": _local_workspaces_for_user(user)}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,32 @@ from app.db import get_conn
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
router = APIRouter(tags=["dashboard"])
|
router = APIRouter(tags=["dashboard"])
|
||||||
|
|
||||||
|
_VERSION = None
|
||||||
|
|
||||||
|
|
||||||
|
def _get_app_version() -> str:
|
||||||
|
"""Read version from VERSION file with caching."""
|
||||||
|
global _VERSION
|
||||||
|
if _VERSION is not None:
|
||||||
|
return _VERSION
|
||||||
|
try:
|
||||||
|
import os
|
||||||
|
version_path = os.path.join(os.path.dirname(__file__), "..", "..", "VERSION")
|
||||||
|
if os.path.exists(version_path):
|
||||||
|
with open(version_path) as f:
|
||||||
|
_VERSION = f.read().strip()
|
||||||
|
else:
|
||||||
|
# Docker fallback
|
||||||
|
version_path = "/app/VERSION"
|
||||||
|
if os.path.exists(version_path):
|
||||||
|
with open(version_path) as f:
|
||||||
|
_VERSION = f.read().strip()
|
||||||
|
else:
|
||||||
|
_VERSION = "0.0.0"
|
||||||
|
except Exception:
|
||||||
|
_VERSION = "0.0.0"
|
||||||
|
return _VERSION
|
||||||
|
|
||||||
|
|
||||||
def _get_user_or_redirect(request: Request):
|
def _get_user_or_redirect(request: Request):
|
||||||
"""Return decoded user or a RedirectResponse to login page.
|
"""Return decoded user or a RedirectResponse to login page.
|
||||||
@@ -188,7 +214,7 @@ def _sidebar_data(request: Request, repos: list[dict], include_workspace: bool =
|
|||||||
"gitea_linked": gitea_linked,
|
"gitea_linked": gitea_linked,
|
||||||
"github_linked": github_linked,
|
"github_linked": github_linked,
|
||||||
"has_active_workspace": has_active_workspace,
|
"has_active_workspace": has_active_workspace,
|
||||||
"app_version": "4.0.3",
|
"app_version": _get_app_version(),
|
||||||
}
|
}
|
||||||
|
|
||||||
sidebar["local_workspaces"] = _local_workspaces_for_user(user)
|
sidebar["local_workspaces"] = _local_workspaces_for_user(user)
|
||||||
|
|||||||
Reference in New Issue
Block a user