Files
matthias 99fd37fc12
CI/CD Pipeline / Lint & Check (push) Successful in 10s
CI/CD Pipeline / Build & Push Docker Image (push) Successful in 1m21s
test: implement unit testing suite with pytest and add pre-push verification hook
2026-05-13 00:12:32 +02:00

36 lines
803 B
Bash
Executable File

#!/bin/sh
# pre-commit hook: runs ruff check (lint) and ruff format --check on staged Python files
# To bypass: git commit --no-verify
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
if [ -z "$STAGED_FILES" ]; then
exit 0
fi
FAILED=0
echo "🔍 Running ruff check (lint)..."
uv run ruff check $STAGED_FILES
if [ $? -ne 0 ]; then
echo " ↳ Fix with: uv run ruff check --fix"
FAILED=1
fi
echo "🎨 Running ruff format --check..."
uv run ruff format --check $STAGED_FILES
if [ $? -ne 0 ]; then
echo " ↳ Fix with: uv run ruff format"
FAILED=1
fi
if [ $FAILED -ne 0 ]; then
echo ""
echo "❌ Pre-commit checks failed. Commit aborted."
echo " To bypass: git commit --no-verify"
exit 1
fi
echo "✅ All checks passed."
exit 0