Commit e98e9dd641
Verified · cmc
Layout: unified · split
.githooks/pre-push added +21
| @@ -0,0 +1,21 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | set -eu | ||
| 3 | |||
| 4 | if ! command -v ruff >/dev/null 2>&1; then | ||
| 5 | echo "pre-push: ruff is not installed or not on PATH" >&2 | ||
| 6 | exit 1 | ||
| 7 | fi | ||
| 8 | |||
| 9 | before_status="$(git status --porcelain)" | ||
| 10 | |||
| 11 | echo "pre-push: running ruff format" | ||
| 12 | ruff format | ||
| 13 | |||
| 14 | after_status="$(git status --porcelain)" | ||
| 15 | if [ "$before_status" != "$after_status" ]; then | ||
| 16 | echo "pre-push: ruff format changed files; commit the formatting before pushing" >&2 | ||
| 17 | exit 1 | ||
| 18 | fi | ||
| 19 | |||
| 20 | echo "pre-push: running ruff check" | ||
| 21 | ruff check | ||