mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-03 04:31:28 +02:00
detect_current_branch() was reading .git/HEAD from settings.base_dir, which points at the data volume (DATA_DIR=/app/data in Docker) and never contains .git. The repo is at /app, so the lookup always failed and the code fell through to the GIT_BRANCH env-var → "main" fallback. The SpoolBuddy device was therefore checking out `main` regardless of which branch Bambuddy itself was running. The old subprocess-based implementation had the same bug but it was masked: the stock Docker image has no `git` binary, so `git rev-parse` raised FileNotFoundError, the except clause swallowed it, and the fallback kicked in. Swapping to filesystem reads exposed the wrong lookup path. Add a module-level _APP_DIR constant (parents[3] of the module file, same depth as config.py uses for its own _app_dir) and read `.git/HEAD` from there. A regression test plants a decoy .git in the data dir and asserts we still pick up the real one from the app root. Per your NO GIT WRITES rule, nothing is staged or committed.