#!/usr/bin/env bash
# Pre-commit: warn if CHANGELOG.md and VERSION are not staged.
# Never exits 1 — this is a reminder, not a blocker.

staged=$(git diff --cached --name-only 2>/dev/null)

# Only check when real source files are being committed (ignore pure docs/assets)
source_staged=$(echo "$staged" | grep -E '\.(py|js|html|css|yml|yaml|json)$' | head -1)
if [ -z "$source_staged" ]; then
  exit 0
fi

missing=()
echo "$staged" | grep -q "CHANGELOG.md" || missing+=("CHANGELOG.md")
echo "$staged" | grep -q "^VERSION$"    || missing+=("VERSION")

if [ ${#missing[@]} -gt 0 ]; then
  echo ""
  echo "  ⚠️  Reminder: the following files were not staged:"
  for f in "${missing[@]}"; do
    echo "       - $f"
  done
  echo ""
  echo "  Update CHANGELOG.md ([Unreleased] section) and bump VERSION if"
  echo "  this commit introduces a user-visible change."
  echo "  Run  python scripts/release.py --minor  to automate a release."
  echo "  Skip with  git commit --no-verify  if this is an internal-only change."
  echo ""
fi

exit 0
