#!/usr/bin/env bash # # Fails when frontend/bindings/ is stale against the bound Go services. # # frontend/bindings/ is generated by `wails3`, not by `go generate`, so # the pre-commit codegen check does not cover it at all. Without this, a # renamed Go struct field or a changed method signature first shows up at # runtime, inside a window, as a binding that never settles. # # v3's generator is a static analyser rather than a build-and-run of the # app, which is what makes this cheap enough to gate a commit on — and # also what makes the build tags matter. It sees only the configuration # it is told about; the one that matters is the one users run, which is # the default tag set (GTK4 + WebKitGTK 6.0). The other two # configurations this repo builds — `indexbuild` and `dev` — add no bound # service, so generating under them would only widen the surface past # what ships. set -euo pipefail cd "$(dirname "$0")/.." TARGET="frontend/bindings" if [ -n "$(git status --porcelain -- "$TARGET")" ]; then echo "bindings-check: $TARGET has uncommitted changes; stage or stash them first" >&2 git status --short -- "$TARGET" >&2 exit 1 fi go tool wails3 generate bindings -clean=true -ts -i >/dev/null 2>&1 if ! git diff --quiet -- "$TARGET"; then echo "bindings-check: $TARGET is out of date with the Go bindings." >&2 echo "Run 'make bindings' and stage the result." >&2 git diff --stat -- "$TARGET" >&2 exit 1 fi # An added or removed *file* is a rename or a new service, which a diff # of tracked paths alone does not see. if [ -n "$(git status --porcelain -- "$TARGET")" ]; then echo "bindings-check: $TARGET gained or lost files." >&2 git status --short -- "$TARGET" >&2 exit 1 fi echo "bindings-check: frontend/bindings is current"