From c153b52641136737faed738e40166f42a902641b Mon Sep 17 00:00:00 2001 From: franzz Date: Tue, 22 Sep 2026 15:53:47 +0200 Subject: [PATCH] Fix data version extraction --- .gitea/workflows/deploy.yml | 6 ++++++ .gitignore | 3 +++ README.md | 2 ++ config.py | 11 +++++++++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 3d75b53..9a82790 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -80,6 +80,12 @@ jobs: - name: Run tests run: .venv-ci/bin/python -m unittest discover -s tests -t . --verbose + # DEPLOY_PATH has no .git (see below), so this is the only chance to + # ask git for the commit. config.py's APP_VERSION reads it back, to + # tell a resumed iOS home-screen session its UI is stale. + - name: Stamp the deployed version + run: git rev-parse --short HEAD > VERSION + # .venv, .env and config.json are excluded, so the # runtime, the stereo pair's learned membership, Spotify's # credentials, and your rooms/ports survive --delete untouched. diff --git a/.gitignore b/.gitignore index e79e70c..3aaa513 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ venv/ # Your own rooms/speakers/ports -- copy config.json.example to config.json config.json + +# Stamped by the Gitea deploy at checkout time -- see config.py's APP_VERSION +VERSION diff --git a/README.md b/README.md index 5ec7085..140c637 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ pip install -r requirements.txt python3 app.py ``` +Needs `git` on PATH and the clone's `.git` left in place — with no `VERSION` file, that's what the panel falls back to at startup for the same stale-UI check. + ### Add a reverse proxy (optional) It serves the panel at `/heos` and refuses everything else on that host; the file ends with the two-line change that puts it at the root instead. diff --git a/config.py b/config.py index 17b462c..974ec94 100644 --- a/config.py +++ b/config.py @@ -109,9 +109,16 @@ APP_NAME = "Heos" # The deployed commit, so the UI can tell when the Pi has moved on to a # newer version and reload itself -- iOS otherwise resumes a suspended -# home-screen session without ever checking back with the server. Empty -# when git isn't available; app.js treats that as "nothing to compare". +# home-screen session without ever checking back with the server. The +# Gitea deploy stamps VERSION at checkout time and ships it (the deployed +# tree otherwise has no .git -- see .gitea/workflows/deploy.yml); a manual +# git-clone install has no VERSION file, so it falls back to asking git +# directly. Empty when neither is available; app.js treats that as +# "nothing to compare". def _app_version() -> str: + version_file = Path(__file__).resolve().parent / "VERSION" + if version_file.exists(): + return version_file.read_text().strip() try: result = subprocess.run( ["git", "rev-parse", "--short", "HEAD"],