#!/bin/sh
# Pre-push gate: run the fast test layers (Go + Angular unit) before code leaves
# the machine. The browser e2e suite is left for CI to keep push quick.
#
# Bypass in a genuine emergency with: git push --no-verify  (discouraged).

echo "pre-push: running unit layers (backend + web) ..."

# Delegate to the one runner so local and CI behave identically. The ps1
# refreshes PATH itself, so this works even in a terminal opened before the
# toolchain was installed.
powershell.exe -NoProfile -ExecutionPolicy Bypass -File ./run-tests.ps1 -Layer unit -NoReport
code=$?

if [ "$code" -ne 0 ]; then
  echo ""
  echo "pre-push blocked: unit tests failed. Fix them, or push --no-verify to override."
  exit 1
fi
exit 0
