commit bc98197d6ccc242d30be9bfd840ededb29dbbd5b parent 2867b1563d57f7ba3973f4fdbb07a98b256385fa Author: Pollux <pollux@pollux.codes> Date: Mon, 10 Feb 2025 01:50:43 -0600 feat(python): Add python format hook Signed-off-by: Pollux <pollux@pollux.codes> Diffstat:
A | python/pre-commit | | | 18 | ++++++++++++++++++ |
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/python/pre-commit b/python/pre-commit @@ -0,0 +1,18 @@ +#!/bin/sh + +code=0 + +for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR | grep "\.py$"` ; do + tmpfile=`mktemp /tmp/XXXXXX` || exit 1 + cp $file $tmpfile + black -q $file 2>> /dev/null + diff -u -p $tmpfile $file 2>> /dev/null + res=$? + rm $tmpfile + if [ $res != 0 ] ; then + echo "Code style error in $file" + code=1 + fi +done + +exit $code