#!/bin/bash
PATCH_FILE="dev.patch"

[ -f "$PATCH_FILE" ] || exit 0

# if we *can* reverse it, it means it's currently applied
if git apply -R --index --check "$PATCH_FILE" >/dev/null 2>&1; then
  echo "⚠️  dev.patch seems to be applied in your working tree."
  read -p "Commit anyway? (yes/no): " A < /dev/tty
  if [[ "$A" != "yes" && "$A" != "y" ]]; then
    echo "❌ Commit aborted. Run: git apply -R dev.patch"
    exit 1
  fi
fi

exit 0