#!/usr/bin/env bash
set -euo pipefail

LICENSE_FILE=".github/license_header.rs"
MISSING=0

while IFS= read -r file; do
  if ! head -n "$(wc -l < "$LICENSE_FILE")" "$file" | diff -q - "$LICENSE_FILE" > /dev/null; then
    echo "❌ Missing or incorrect license in: $file"
    MISSING=1
  fi
done < <(find src/ -name "*.rs")

if [ $MISSING -eq 1 ]; then
  echo "Some files are missing the correct license header."
  exit 1
else
  echo "✅ All files have the correct license header."
fi
