git-hook to prevent pushing php-errors
✓ Published0🌍 Public
HHoffmannP
Last edited Apr 26, 2018
Created on Apr 26, 2018
This example demonstrates a Git pre-push hook that automatically scans outgoing PHP commits for syntax errors and aborts the push if any are found. It shows a shell script that uses `git diff-tree` to identify changed files, filters for `.php` extensions, and pipes each file through `php -l` (the PHP linter) to validate syntax. The hook receives pushed refs via standard input and acts on the SHA ranges, storing results in the local ref variables. It relies on standard Unix tools like `grep` and `xargs` to orchestrate the per-file linting process.
AI-generated description