在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:BrainMaestro/composer-git-hooks开源软件地址:https://github.com/BrainMaestro/composer-git-hooks开源编程语言:PHP 99.3%开源软件介绍:composer-git-hooks
InstallAdd a {
"extra": {
"hooks": {
"pre-commit": [
"echo committing as $(git config user.name)",
"php-cs-fixer fix ." // fix style
],
// verify commit message. ex: ABC-123: Fix everything
"commit-msg": "grep -q '[A-Z]+-[0-9]+.*' $1",
"pre-push": [
"php-cs-fixer fix --dry-run ." // check style
"phpunit"
],
"post-merge": "composer install"
"...": "..."
}
}
} Then install with composer require --dev brainmaestro/composer-git-hooks This installs the Note: hooks declared in the Global supportYou can also install it globally. This feels much more natural when composer global require --dev brainmaestro/composer-git-hooks All commands have global support (besides testing the hooks. Still requires being in the directory with the Optional ConfigurationStop on failureWhen a hook is a sequence of commands, it can be useful to stop the execution when a command fails. Specify the impacted hooks in the {
"extra": {
"hooks": {
"config": {
"stop-on-failure": ["pre-push"]
},
"pre-push": [
"php-cs-fixer fix --dry-run --stop-on-violation .",
"phpunit"
],
}
}
} Always be sure to run the update command after changing the Custom hooksCustom hooks can be added to the {
"extra": {
"hooks": {
"config": {
"custom-hooks": ["pre-flow-feature-start"]
},
"pre-flow-feature-start": [
"echo 'Starting a new feature...'"
]
}
}
} Always be sure to run the update command after changing the ShortcutAdd a {
"scripts": {
"cghooks": "vendor/bin/cghooks",
"...": "..."
}
} Composer EventsAdd the following events to your {
"scripts": {
"post-install-cmd": "cghooks add --ignore-lock",
"post-update-cmd": "cghooks update",
"...": "..."
}
} UsageAll the following commands have to be run either in the same folder as your Adding HooksAfter installation is complete, run
The If the Updating HooksThe update command which is run with This works similarly when used with Removing HooksHooks can be easily removed with Hooks can also be removed by passing them as arguments. The command
CAREFUL: If the lock file was tampered with or the force option was used, hooks that already existed before using this package, but were specified in the composer scripts config will be removed as well. That is, if you had a previous This also does not have a fallback to Listing hooksHooks can be listed with the Common OptionsThe following options are common to all commands.
Each command also has a flag Testing HooksHooks can be tested with ContributingPlease see CONTRIBUTING for details. CreditsRelatedLicenseThe MIT License (MIT). Please see License File for more information. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论