From 2381706465cb3b6b46026d0d953476afe129898f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 23 Sep 2024 20:52:13 +0200 Subject: [PATCH] chore: Refactor pre-commit hook to improve performance and readability --- hooks/pre-commit | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 70ffd76ac..99c925630 100644 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -4,15 +4,7 @@ if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then exec < /dev/tty fi -$(pwd)/vendor/bin/pint $@ -# Get the list of files that were modified by Pint -modified_files=$(git diff --name-only --cached) -echo $modified_files -# Add the modified files back to the staging area -if [ -n "$modified_files" ]; then - echo "Adding fixed files to the commit..." - git add $modified_files -fi - - +files=$(git diff --cached --name-only --diff-filter=ACM -- '*.php'); +$(pwd)/vendor/bin/pint $files -q +git add $files