#!/bin/sh
# SafeGuardian pre-push hook
# Automatically installed by: node safeGuardian/install.js

REPO_ROOT=$(git rev-parse --show-toplevel)
GUARDIAN_CLI="$REPO_ROOT/safeGuardian/cli.js"

if [ ! -f "$GUARDIAN_CLI" ]; then
  echo "SafeGuardian: cli.js not found at $GUARDIAN_CLI — skipping scan"
  exit 0
fi

node "$GUARDIAN_CLI" "$REPO_ROOT"
EXIT_CODE=$?

if [ $EXIT_CODE -ne 0 ]; then
  echo ""
  echo "Push aborted by SafeGuardian. Fix the issues above and try again."
  echo "To skip (not recommended): git push --no-verify"
  exit 1
fi

exit 0
