Something went wrong. Try again.
Something went wrong. Try again.
754 B · 28 lines
at trunk
1234567891011121314151617181920212223242526272829#!/bin/bash# Set up with `pushd .git/hooks; ln -s ../../hooks/pre-commit pre-commit; popd`
set -eux
if git rev-parse --verify HEAD >/dev/null 2>&1then against=HEADelse # Initial commit: diff against an empty tree object against=$(git hash-object -t tree /dev/null)fi# cat always has error code 0# ignore deleted files (can't be formatted)filenames=$(git diff --cached --name-only --diff-filter=d $against | grep '\.py$' | cat)# If changed files include scrapscript.py, run testsif echo $filenames | grep scrapscriptthen python3 ./scrapscript_tests.pyfi
# If there are any other changed Python files, make sure they lintif [ -n "$filenames" ]then ruff format --check $filenames ruff check $filenames mypy --strict $filenamesfi