#!/bin/bash
# install-hooks.sh — Install the post-commit hook that automates lake build
# ingestion into Postgres.
#
# Run this from the repo root after cloning:
#   bash scripts/install-hooks.sh

HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
cat > "$HOOKS_DIR/post-commit" << 'HOOKEOF'
#!/bin/sh
# Git LFS post-commit hook
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
git lfs post-commit "$@"

# Lake build ingestion (async, non-blocking)
# Runs the build and ingests results into Postgres on neon-64gb.
python3 "/home/allaun/Research Stack/4-Infrastructure/shim/lake_build_ingest.py" Compiler --dir /home/allaun/SilverSight --actor opencode >/dev/null 2>&1 &
HOOKEOF
chmod +x "$HOOKS_DIR/post-commit"
echo "Installed post-commit hook in $HOOKS_DIR/post-commit"
