PHP code example of aequasi / git-hook-handler
1. Go to this page and download the library: Download aequasi/git-hook-handler library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aequasi / git-hook-handler example snippets
yaml
# git-hook.yml
config:
commit-on-error : true # or false
pre-commit:
# Simple command
- bin/phpcs
# or more complex command
- phpunit:
description : 'Run PHPUnit'
command : phpunit
exitcode : 0
phpcs-fixer:
description : 'Checking PHP Syntax with PHP-CS-FIXER'
exitcode : 0
command : >4
COMMIT_RANGE='HEAD~..HEAD' &&
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "${COMMIT_RANGE}") &&
if ! echo "${CHANGED_FILES}" | grep -qE "^(\\.php_cs(\\.dist)?|composer\\.lock)$"; then IFS=$'\n' EXTRA_ARGS=('--path-mode=intersection' '--' ${CHANGED_FILES[@]}); fi
&& ./vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --using-cache=no "${EXTRA_ARGS[@]}"
post-merge:
command_name:
description : 'lorem ipsum'
command : 'mycommand'
exitcode : 0