结合公司项目制定,可供参考
需要增加Git Commit 校验规则,说明如下:
- 需使用:xxx@eeoa.com 邮箱提交,不允许使用其他邮箱
- git commit 需要关联 Tapd 任务Id,否则不允许提交(--doc 指令除外)
- git commit -m 内容区最多可输入500个字符,尽量简短描述清楚即可
- 建议 git commit -m '--story --user message',顺序书写提交(story->user->message)
Commit 的类别,使用下面 8 个标识:
- feat:新功能(feature)
- fix:修补 bug
- docs:文档(documentation)
- style: 格式(不影响代码运行的变动)
- refactor:重构(即不是新增功能,也不是修改 bug 的代码变动)
- test:增加测试
- chore:构建过程或辅助工具的变动
- revert: 回滚代码到历史提交
设置邮箱(已设置可忽略)
# 获取
git config user.name # 查看用户名
git config user.email # 查看邮箱
# or 全局
git config --global user.name # 查看用户名
git config --global user.email # 查看邮箱
# 设置
git config user.name xxx
git config user.email xxx@eeoa.com
# or 全局
git config --global user.name xxx
git config --global user.email xxx@eeoa.com
关联Tapd
可以通过如下的 commit message 将 commit 与 tapd的story/bug/task 进行关联
# 关联需求
--story=[story id] --user=[username in tapd]
# 关联任务
--task=[task id] --user=[username in tapd]
# 关联缺陷
--bug=[bug id] --user=[username in tapd]
# 关联文档(特殊)
--doc=[文档链接]
代码示例:
git commit -m "feat: --story=TAPDId --user=TAPD用户名 描述信息"
# 关联多个任务
git commit -m "feat: --story=TAPDId --story=TAPDId ... --user=TAPD用户名 add tapd description to README.md"
#关联文档(特殊)
git commit -m "feat: --doc=https://eeoof.notion.site/Git-Commit-Tapd-a24d034dc8ed4a14af082bd46ba33a68 描述"
操作步骤:
1、快速获取TapdId 及其关键字,作为提交 commit message提交内容
2、在根目录执行
git add .
git commit -m '--story=1035323 --user=白羽 LMS git commit 钩子 <https://www.tapd.cn/45976096/s/2321361>'
git push // 提交
3、关联后的内容查看区:
Tapd列表 - 进入Tapd详情 - 更多 - Gitlab 提交即可!
完成!