Add in-app self-update via git (Hilfe menu)

New Updater class + "Hilfe" menubar:
- "Nach Update suchen": git fetch + count of new upstream commits.
- Quiet background check on start; surfaces via status bar + menu label.
- Install: git merge --ff-only, pip install if requirements.txt changed,
  then restart via os.execv. data/ is git-ignored and untouched.
- Fast-forward only; diverged history or offline -> clear message, no action.
- Inert unless run from a git clone with git on PATH.

Also: "Version…" menu item shows the installed commit.

Verified against throwaway git repos (check / ff-update / diverged / no-op /
non-clone) and via GUI build on Python 3.14 / Tk 9.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-07 22:06:51 +02:00
parent e3bbd4d264
commit 1bed723363
7 changed files with 330 additions and 10 deletions
+26 -5
View File
@@ -7,16 +7,24 @@ during install.
## 1. System packages
Tkinter is not bundled with the system Python on Mint and must be installed
separately:
separately. `git` is needed for the in-app updater:
```bash
sudo apt update
sudo apt install python3-tk python3-venv python3-pip
sudo apt install python3-tk python3-venv python3-pip git
```
## 2. Get the code
Put the project folder somewhere stable, e.g. `~/Apps/DRK_Blutspende_Orte`.
**Clone it** (don't download a zip) the in-app "Nach Update suchen" only works
from a git clone:
```bash
mkdir -p ~/Apps && cd ~/Apps
git clone <repo-url> DRK_Blutspende_Orte
```
Put it somewhere stable, e.g. `~/Apps/DRK_Blutspende_Orte`.
## 3. Create a virtual environment and install dependencies
@@ -94,13 +102,26 @@ that. The macOS CommandLineTools Python used during development ships Tk 8.5 and
## Updating
**From inside the app:** menu **Hilfe ▸ Nach Update suchen**. The app also
checks quietly on start and offers the update if there is one. It fast-forwards
to the server version, reinstalls dependencies if `requirements.txt` changed,
and restarts itself. `data/` is never touched.
For this to work the app must run from a **git clone** (step 2) whose `.venv`
was made with the same Python it runs on, and `git` must be installed. The
updater only ever fast-forwards if the local copy has been changed by hand it
refuses and says to get in touch.
**Manually** (equivalent):
```bash
cd ~/Apps/DRK_Blutspende_Orte
git pull # once the project is in git
git pull --ff-only
.venv/bin/pip install -r requirements.txt
```
## Data location
All state is in `data/orte.csv` next to `app.py`. To back up the app, copy that
one file. To move to a new laptop, copy the whole folder and redo steps 1 & 3.
one file (plus `data/backups/` if you want the history). To move to a new
laptop, clone the repo again and redo steps 1 & 3; copy `data/orte.csv` across.