Files
strava-mcp-server/scripts/hooks/pre-commit
T

27 lines
642 B
Bash
Executable File

#!/bin/sh
# pre-commit hook: runs ruff check on staged Python files before every commit
# To bypass: git commit --no-verify
# Get list of staged Python files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
if [ -z "$STAGED_FILES" ]; then
exit 0
fi
echo "🔍 Running ruff check on staged files..."
uv run ruff check $STAGED_FILES
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo ""
echo "❌ ruff check failed. Commit aborted."
echo " Fix the issues above or run: uv run ruff check --fix"
echo " To bypass: git commit --no-verify"
exit 1
fi
echo "✅ ruff check passed."
exit 0