#!/bin/sh
# Conventional Commits + layer-scope consistency check.
# Enable locally with:  git config core.hooksPath tools/git-hooks
# Receives the path to the commit message file as $1.
DIR=$(dirname "$0")
ROOT=$(cd "$DIR/../.." && pwd)
# Prefer the repo venv (global `python` may be a Windows Store stub / missing).
if [ -x "$ROOT/.venv/Scripts/python.exe" ]; then
  PY="$ROOT/.venv/Scripts/python.exe"
elif [ -x "$ROOT/.venv/bin/python" ]; then
  PY="$ROOT/.venv/bin/python"
elif command -v python3 >/dev/null 2>&1; then
  PY=python3
elif command -v python >/dev/null 2>&1; then
  PY=python
else
  echo "commit-msg hook: python not found; skipping check." >&2
  exit 0
fi
"$PY" "$DIR/validate_commit_msg.py" "$1"
