#!/bin/bash
# Redirect output to stderr.
exec 1>&2

found_errors=0

while read st file; do

    if [[ $file == *.py ]] && ! ruff check -s "$file" --ignore "FIX"; then
        echo "Ruff check failed for file: $file"
        found_errors=1
    fi

done < <(git diff --diff-filter dr --cached --name-status)

if [[ $found_errors -eq 1 ]]; then
        exit 1
fi
