git - 对某些分支使用 git-hooks(使用 Husky 和 git-branch-is)
问题描述
我使用husky和git-branch-is作为 git 钩子。在我的 package.json 下面
{
"scripts": {
"test": "jest",
...
},
"husky": {
"hooks": {
"pre-commit": "git-branch-is master && npm test",
"pre-push": "git-branch-is master && npm test"
}
}
使用从分支功能/802提交的此选项,我重新筛选以下错误
Error: Current branch is "feature/802", not "master".
问题
- 如何禁用以“功能”开头的分支的 git 钩子
- 仅对master和development分支应用钩子。
- 这可以在不使用 bash 脚本的情况下实现吗?
解决方案
这对我有用。git-branch-is
没有必要。
{
"hooks": {
"commit-msg": "if [[ $(git rev-parse --abbrev-ref HEAD) = develop ]]; then commitlint -E HUSKY_GIT_PARAMS; fi"
}
}
推荐阅读
- reactjs - ModuleFederationPlugin for React and Angular combined
- c++ - 部分特化类的成员定义
- python-3.x - Why matplotlib does not show the scatter plot in a second cell of a Jupyter notebook?
- android - android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork error while android app makes http api
- delphi - Delphi 6 FormatSetting uLkJson.pas
- python - 'at=error code=H10' WHILE DEPLOYING TO HEROKU
- javascript - 检查嵌套对象中的空值
- c# - 如何根据文件名将文件添加到列表中
- apache-nifi - 如何重命名 NiFi Registry 中的流程?
- django - Django 要求在 url 中登录