mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-09 01:35:18 +02:00
Track a project pre-commit hook under scripts/hooks/ that regenerates openapi.json when server source is staged, and auto-stages the updated spec into the commit. Zero external dependencies — plain bash + cargo. Enable via `git config core.hooksPath scripts/hooks`. The CI drift test remains the authoritative check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
15 lines
558 B
Bash
Executable file
15 lines
558 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Regenerate openapi.json when the server API surface changes.
|
|
set -euo pipefail
|
|
|
|
staged=$(git diff --cached --name-only --diff-filter=ACMR)
|
|
|
|
echo "$staged" | grep -qE '^(crates/omnigraph-server/src/.*\.rs|crates/omnigraph-server/Cargo\.toml)$' || exit 0
|
|
|
|
echo "[pre-commit] regenerating openapi.json..."
|
|
OMNIGRAPH_UPDATE_OPENAPI=1 cargo test -p omnigraph-server --test openapi openapi_spec_is_up_to_date --quiet
|
|
|
|
if ! git diff --quiet -- openapi.json; then
|
|
git add openapi.json
|
|
echo "[pre-commit] openapi.json updated and staged"
|
|
fi
|