#!/usr/bin/env bash
# adapters/wordpress/hooks/post-checkout — WordPress adapter overlay
#
# Mirror of the upstream post-checkout: reminds operators to refresh
# Composer autoload when switching branches that touch composer.lock.
# Kept WP-adapter-only because Composer is PHP/WordPress-specific.

set -euo pipefail

prev_head="${1:-}"
new_head="${2:-}"
branch_checkout="${3:-0}"

[ "$branch_checkout" != "1" ] && exit 0
[ -z "$prev_head" ] || [ -z "$new_head" ] && exit 0

if git diff --name-only "$prev_head" "$new_head" 2>/dev/null | grep -q '^composer\.lock$'; then
  echo "[wordpress] composer.lock changed across this checkout — consider: composer install" >&2
fi
exit 0
