git commit 规范及 changelog

使用插件standard-versionconventional-changelog生成 changelog 文档的方法。

具体步骤如下:
1. 安装插件

在 package.json 文件中补充添加如下内容:

"scripts": {
   "commit": "git-cz",
   "release": "standard-version",
   "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
   "eslint": "eslint --fix --format codeframe 'src/**.js'",
   "log": "conventional-changelog"
 },
 "devDependencies": {
    "@commitlint/cli": "^8.3.5",
    "@commitlint/config-angular": "^8.3.4",
    "@commitlint/config-conventional": "^8.2.0",
    "cz-conventional-changelog": "^3.1.0",
    "husky": "^3.1.0",
    "lint-staged": "^10.1.1",
    "standard-version": "^7.0.1"
 },
 "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
 },
  "commitlint": {
    "extends": [
      "@commitlint/config-conventional"
    ]
 },
  "lint-staged": {
    "src/**.js": [
      "eslint --fix"
    ]
 }

然后 npm run install安装插件。

链接:

2. 相关指令说明:
  • 使用 conventional-changelog 标准提交
npm run commit
  • 自动生成版本号(版本号默认加 0.0.1)并修改 changelog 文件
npm run release
  • 生成并更新 changelog 文档
npm run changelog
  • eslint 代码检查
npm run eslint
  • log 在终端打印 changelog 内容
npm run log

如果想知道更多的指令,可以在终端输入: standard-version --helpconventional-changelog --help

目前使用最广的是基于 Angular 约定提交,用于说明 commit 的类别,只允许使用下面 7 个标识:

feat:新功能(feature)

fix:修补 bug

docs:文档(documentation)

style: 格式(不影响代码运行的变动)

refactor:重构(即不是新增功能,也不是修改 bug 的代码变动)

test:增加测试

chore:构建过程或辅助工具的变动

如果 type 为 feat 和 fix,则该 commit 将肯定出现在 Change log 之中。其他情况(docs、chore、style、refactor、test)可以自己定义。

angular 规范链接

生成changelog文档如图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lancnn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值