From: Scott Worley Date: Sat, 9 May 2026 08:04:19 +0000 (-0700) Subject: git pre-commit hook X-Git-Tag: v1.1.1~1 X-Git-Url: http://git.scottworley.com/nix-pin-deps/commitdiff_plain/93199b8c58b43817c134be73d7e9a5b5e319cbb5?ds=sidebyside;hp=bd935ce69adee94e9095f1f3c13c1448a1d3724b git pre-commit hook --- diff --git a/git-pre-commit-hook b/git-pre-commit-hook new file mode 100755 index 0000000..85b4445 --- /dev/null +++ b/git-pre-commit-hook @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Copy me to .git/hooks/pre-commit + +set -e + +cleanup() { + if [[ "$D" && -e "$D" ]];then + rm -rf "$D" + fi +} +trap cleanup EXIT + +D=$(mktemp -d) +[[ "$D" && -d "$D" ]] + +git checkout-index --prefix="$D/" -a +pushd "$D" + +nix-shell --arg lint true --run './test.sh lint' + +popd diff --git a/test.sh b/test.sh index 146f901..c143632 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash set -e @@ -8,7 +8,7 @@ find . -name build -prune -o -name dist -prune -o -name '*.py' -print0 | if [ "$1" = lint ];then pylint --reports=n --persistent=n --ignore-imports=y \ - -d fixme,invalid-name,missing-docstring,subprocess-run-check,too-few-public-methods *.py + -d fixme,invalid-name,missing-docstring,subprocess-run-check,too-few-public-methods -- *.py formatting_needs_fixing=$( find . -name '*.py' -print0 |