this repo has no description
at trunk 28 lines 754 B view raw
1#!/bin/bash 2# Set up with `pushd .git/hooks; ln -s ../../hooks/pre-commit pre-commit; popd` 3 4set -eux 5 6if git rev-parse --verify HEAD >/dev/null 2>&1 7then 8 against=HEAD 9else 10 # Initial commit: diff against an empty tree object 11 against=$(git hash-object -t tree /dev/null) 12fi 13# cat always has error code 0 14# ignore deleted files (can't be formatted) 15filenames=$(git diff --cached --name-only --diff-filter=d $against | grep '\.py$' | cat) 16# If changed files include scrapscript.py, run tests 17if echo $filenames | grep scrapscript 18then 19 python3 ./scrapscript_tests.py 20fi 21 22# If there are any other changed Python files, make sure they lint 23if [ -n "$filenames" ] 24then 25 ruff format --check $filenames 26 ruff check $filenames 27 mypy --strict $filenames 28fi