#!/usr/bin/env bash
# Usage: gather-diff.sh <WORKTREE_PATH> <BASE_SHA> <HEAD_SHA> <spec-path> [<spec-path> ...]
# Outputs all data needed for a code gate review. Run before applying code-review-prompt.md.

set -euo pipefail

WORKTREE="$1"
BASE="$2"
HEAD="$3"
shift 3
SPECS=("$@")

echo "=== COMMIT LOG ==="
git -C "$WORKTREE" log --oneline "${BASE}..${HEAD}"

echo ""
echo "=== COMMIT STAT ==="
git -C "$WORKTREE" show --stat "$HEAD"

echo ""
echo "=== DIFF ==="
git -C "$WORKTREE" diff "${BASE}..${HEAD}"

echo ""
echo "=== CLAUDE.md ==="
cat "$WORKTREE/CLAUDE.md" 2>/dev/null || echo "(not found)"

for spec in "${SPECS[@]}"; do
  echo ""
  echo "=== SPEC: $spec ==="
  cat "$spec" 2>/dev/null || echo "(not found: $spec)"
done
