aequasi / git-hook-handler
Git 钩处理器
2.1.2
2020-03-23 18:27 UTC
Requires
- symfony/console: ^2.3|^3.0|^4.0|^5.0
- symfony/process: ^2.3|^3.0|^4.0|^5.0
- symfony/yaml: ^2.3|^3.0|^4.0|^5.0
Requires (Dev)
- composer/composer: ^1.0
README
使用方法
只需在项目基本目录中创建一个 git-hooks.yml
文件,并填写您想运行的命令数组
# 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
然后,在您的 composer.json 中放置以下内容,然后运行 composer install
或 composer update
# composer.json "scripts": { "pre-update-cmd": "Aequasi\\HookHandler\\HookScript::install", "pre-install-cmd": "Aequasi\\HookHandler\\HookScript::install" }