From 93199b8c58b43817c134be73d7e9a5b5e319cbb5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 9 May 2026 01:04:19 -0700 Subject: [PATCH 1/1] git pre-commit hook --- git-pre-commit-hook | 22 ++++++++++++++++++++++ test.sh | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 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 | -- 2.51.2