Files
gh-christianlouis-docuelevate/scripts/run-ruff-and-fix.sh
copilot-swe-agent[bot] 4e2353b214 style: ruff auto-fixes
2026-02-13 21:01:04 +00:00

41 lines
1.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
# Script for local/agent use before creating a PR.
# Installs ruff, checks, tries --fix, commits fixes, and fails if issues remain.
echo "Installing ruff..."
python -m pip install --upgrade pip --quiet
pip install ruff --quiet
echo "Running ruff check..."
if ruff check app/ tests/; then
echo "✅ ruff: no issues found"
exit 0
else
echo "⚠️ ruff: issues found — running ruff --fix"
ruff check app/ tests/ --fix
# Check if there are any changes to commit
git add -A
if git diff --staged --quiet; then
echo "️ No staged changes after ruff --fix"
else
git commit -m "style: ruff auto-fixes" || true
echo "✅ Committed ruff fixes"
fi
echo "Re-running ruff check after fixes..."
if ruff check app/ tests/; then
echo "✅ ruff: all issues fixed"
exit 0
else
echo "❌ ruff: issues remain after auto-fix" >&2
echo ""
echo "The following issues could not be auto-fixed and require manual intervention:"
echo ""
ruff check app/ tests/
exit 1
fi
fi