bigtallbill / hooker
可扩展的PHP提交钩子
0.1.3
2015-03-07 23:05 UTC
Requires
- symfony/console: 2.6.4
Requires (Dev)
- phpunit/phpunit: 4.3.*
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2024-09-25 13:55:37 UTC
README
hooker
一个可扩展的php提交钩子
安装
- 下载二进制文件https://github.com/bigtallbill/hooker/releases/tag/0.1.0
- 将二进制发布版复制到您的PATH加载的目录
- 使文件可执行
chmod a+x hooker
- 检查安装
which hooker
用法
- 打开终端并切换到目标仓库
- 运行
hooker install
这将安装一个hooker.json配置文件,并更新此仓库的提交钩子文件以执行hooker
现在当您尝试提交某些内容时,hooker将执行。
hooker.json配置
hooker.json配置文件包含每种类型钩子的设置。
{
"preCommit": {},
"commitMsg": {
"firstWordImperative": true,
"maxSummaryLength": 50,
"maxContentLength": 72,
"summaryIgnoreUrls": true,
"contentIgnoreUrls": true,
"lineAfterSummaryMustBeBlank": true,
"scripts": {
"after": [
{
"cmd": "runtests.sh",
"passGitArgs": false,
""
}
]
}
}
}
"scripts"
每种钩子类型都可以有scripts
元素。这允许您执行非hooker原生检查的任意代码。
"scripts": {
"after": [
{
"cmd": "runtests.sh"
}
]
}
"after"键定义何时运行脚本(目前只有"after")。"after"意味着在hooker自己的内部代码之后运行该脚本。
然后我们有要运行的脚本数组。
以下是一个示例脚本对象
{
"cmd": "runtests.sh",
"passGitArgs": false,
"relativeToRepo": false
}
"cmd"是要执行的命令
"passGitArgs"当设置为true时,将git参数追加到脚本的现有参数
"relativeToRepo"相对于仓库执行此脚本。目前这相当愚蠢,它将只把仓库路径添加到cmd。
"commitMsg"
- firstWordImperative = 确保提交消息的第一词是祈使语气现在时态
- maxSummaryLength = 摘要行的最大长度
- maxContentLength = 消息体的最大长度
- summaryIgnoreUrls = 忽略包含url的行的长度(如果无法控制url的长度很有用)
- contentIgnoreUrls = 忽略包含url的行的长度(如果无法控制url的长度很有用)
- lineAfterSummaryMustBeBlank = 确保摘要后的行是空的