本项目提供了两种方式在 CNB 中对 Pull Request 的 commit 进行规范检查。
在 .cnb.yml 文件中添加以下配置:
main:
pull_request:
- stages:
- name: commitlint
image: cnbcool/commitlint
<type>[optional scope]: <description> [optional body] [optional footer(s)]
常见的 type 包括:
feat: 新功能fix: 修复 bugdocs: 文档更新style: 代码格式调整refactor: 重构test: 测试相关chore: 构建过程或辅助工具的变动在 .cnb.yml 文件中添加以下配置:
main:
pull_request:
- stages:
- name: 自定义 commitlint
script: .ci/git_commit_check.sh
<前缀>/<描述> --story=需求ID 或 --task=任务ID 或 --bug=缺陷ID
支持的前缀:
feature: 新功能fix: 修复问题doc: 文档更新update: 更新style: 样式调整chore: 杂项refactor: 重构test: 测试release: 发布uat: UAT 相关ui/UI: UI 相关示例:
feature/用户登录功能 --story=12345 fix/修复登录bug --bug=67890 test/添加单元测试 --task=54321
^[a-zA-Z0-9._-]+$.ci/email_suffixes.txttencent.com
主要的检查脚本,包含所有校验逻辑。
克隆项目
git clone <repository-url>
cd commit-lint
选择检查方式
.cnb.yml 文件自定义配置(方式二)
.ci/email_suffixes.txt 添加允许的邮箱后缀.ci/git_commit_check.sh 中的校验规则提交测试
git commit -m "test/测试提交 --task=123"