Created
June 16, 2022 12:02
-
-
Save AnrDaemon/46192f636d86230f897bf22f13d1d601 to your computer and use it in GitHub Desktop.
Git hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=$( git hash-object -t tree /dev/null ) | |
fi | |
# Redirect output to stderr. | |
exec 1>&2 | |
# PHP linting, excluding deleted files | |
git diff --cached --diff-filter=d --name-only -z $against -- \*.php | xargs --null --no-run-if-empty --max-args=1 php-8.0 -l -f > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment