add safe context sync script

This commit is contained in:
Oskar Kapala 2026-05-04 21:44:35 +02:00
parent 67117a0551
commit bcfa0094f4
2 changed files with 43 additions and 0 deletions

View file

@ -31,6 +31,12 @@ The documentation is based only on stated facts. Missing details are recorded as
- [Joplin Server](docs/joplin-server.md) - [Joplin Server](docs/joplin-server.md)
- [Unknowns and clarification questions](docs/questions.md) - [Unknowns and clarification questions](docs/questions.md)
## Workflow
- Start Codex with `./start-codex.sh`.
- Start Aider with `./start-aider.sh`.
- Sync shared context only with `./sync-context.sh` from the repo root after updating `codex_context.yaml`.
## Known facts ## Known facts
- The homelab has one known main server: Raspberry Pi 5. - The homelab has one known main server: Raspberry Pi 5.

37
saturn/sync-context.sh Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
if [[ -z "$REPO_ROOT" ]]; then
echo "Not inside a git repository" >&2
exit 1
fi
if [[ "$(pwd)" != "$REPO_ROOT" ]]; then
echo "Run this script from the repo root" >&2
exit 1
fi
mapfile -t status_lines < <(git status --porcelain=v1 --untracked-files=all)
for line in "${status_lines[@]}"; do
path="${line:3}"
if [[ "$path" != "codex_context.yaml" ]]; then
echo "Refusing to sync: only codex_context.yaml may be changed" >&2
exit 1
fi
done
git pull --rebase
if git diff --quiet -- codex_context.yaml && git diff --cached --quiet -- codex_context.yaml; then
echo "No context changes to sync"
exit 0
fi
python3 -c "import yaml; yaml.safe_load(open('codex_context.yaml'))"
git add codex_context.yaml
git commit -m "update shared context"
git push