Skip to content

Instantly share code, notes, and snippets.

@AnrDaemon
Created June 16, 2022 12:02
Show Gist options
  • Save AnrDaemon/46192f636d86230f897bf22f13d1d601 to your computer and use it in GitHub Desktop.
Save AnrDaemon/46192f636d86230f897bf22f13d1d601 to your computer and use it in GitHub Desktop.
Git hooks
#!/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