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

cd "$(git rev-parse --show-toplevel)"

# Re-add previously staged files so formatting changes are included in the commit.
# Exclude deleted files since they no longer exist on disk.
staged=$(git diff --cached --name-only --diff-filter=d)

echo "Running ruff format check..."
make format
if [ -n "$staged" ]; then
    git add $staged
fi

echo "Running unit tests..."
make test
