commitlint+husky规范commit日志

更新时间:2023-05-16 20:09:20 阅读: 评论:0

commitlint+husky 规范commit ⽇志
为了⽅便开发团队协作开发, -m 中的信息需要有个规范,⽅便直观的看出每次commit ⽬的
主要说下安装步骤和commit 规范标准,有问题欢迎探讨指出~~
>>>>>>安装步骤>>>>>#### ⼀.安装node,从下载对应平台的安装程序 安装成功后,终端执⾏命令 node -v 和 npm -v 可以查看安装的node,npm的版本号
⼆:cd到项⽬⽬录,创建package.json⽂件 1.通过下⾯命令⾏可以直接创建默认package.json⽂件 npm init -y 2.通过下⾯命令⾏⼀步步输⼊创建⾃定义的package⽂件内容 (注意package name:不可以以⼤写字母开头,下⾯有提⽰) npm init $ node -v
v10.13.0
$ npm -v
6.4.1
执⾏完以下命令可以在项⽬根⽬录看到package-lock.json,package.json⽂件三:安装套件@commitlint/config-angular @commitlint/cli、husky $ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess nsible defaults.
See `npm help json` for definitive documentation on the fields
and exactly what they do.tx是什么意思
U `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (runloop) Runloop
Sorry, name can no longer contain capital letters.
package name: (runloop) runloop
version: (1.0.0)
description: 测试commitlint
entry point: (index.js)
test command:
git repository: (/wei3715/RunLoop.git)
keywords:
author: zww
licen: (ISC)
About to write to /Urs/jolly/Desktop/up/lf/RunLoop/package.json:
{
"name": "runloop",
"version": "1.0.0",
"description": "测试commitlint",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+/wei3715/RunLoop.git"
},
"author": "zww",
"licen": "ISC",
"bugs": {
"url": "/wei3715/RunLoop/issues"
},
"homepage": "/wei3715/RunLoop#readme"
}
Is this OK? (yes) yes
安装完成后package.json⽂件的内容:四:将husky hook加⼊到到package.json⽂件中
//1. 安装套件@commitlint/config-angular @commitlint/cli $ npm install --save-dev @commitlint/config-angular @commitlint/cli
npm notice created a lockfile as package-lock.json. You should commit this file.
+ @commitlint/config-angular@7.1.2
+ @commitlint/cli@7.2.1
added 149 packages from 62 contributors and audited 388 packages in 28.666s
found 0 vulnerabilities
//2.安装套件husky
$ npm install --save-dev husky
> husky@1.1.4 install /Urs/jolly/Desktop/up/lf/RunLoop/node_modules/husky
> node husky install
husky > tting up git hooks
husky > done
+ husky@1.1.4
added 41 packages from 13 contributors and audited 466 packages in 10.866s
found 0 vulnerabilities
{  "name": "runloop",
"version": "1.0.0",
"description": "测试commitlint",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
ldk"type": "git",
"url": "git+/wei3715/RunLoop.git"
},
"author": "zww",
"licen": "ISC",
"bugs": {
"url": "/wei3715/RunLoop/issues"
},
"homepage": "/wei3715/RunLoop#readme",
paula"devDependencies": {
"@commitlint/cli": "^7.2.1",
"@commitlint/config-angular": "^7.1.2",
"husky": "^1.1.4"
}
}
五:创建fig.js⽂件到项⽬根⽬录,设定规范
编辑输⼊以下⼀⾏内容即可,这个⽂件代表以后commit -m 后⾯的提交应遵循的规范
好的,⼤功告成~~完成之后项⽬根⽬录会多出下⾯这⼏个⽂件测试效果 下⾯执⾏commit命令测试下效果:
{  "name": "runloop",
"version": "1.0.0",  "description": "测试
commitlint",  "main": "index.js",
"scripts": {    "test": "echo \"Error: no test specified\" && exit 1"
},  "repository": {
"type": "git",
"url": "git+/wei3715/RunLoop.git"
},
"author": "zww",
"licen": "ISC",
"bugs": {
"url": "/wei3715/RunLoop/issues"
},
"homepage": "/wei3715/RunLoop#readme",
"devDependencies": {
"@commitlint/cli": "^7.2.1",
"@commitlint/config-angular": "^7.1.2",
"husky": "^1.1.4"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}浸泡村
}
}
$ fig.js
可以看到如果不按照规范书写commit的⽇志会提⽰报错
下⾯输⼊正确的commit ⽇志信息:注意冒号后⾯要留空格,下⾯有介绍具体的编辑规范信息
测试通过后,将下⾯⽂件添加到忽略⽂件.gitignore中
>>>>>>下⾯是commit规范>>>>>#commit message的格式$ git status
On branch master
英语专业论文题目Your branch is up to date with 'origin/master'.Untracked files:
(u "git add <file>..." to include in what will be committed)
node_modules/
package-lock.json
package.json
nothing added to commit but untracked files prent (u "git add" to track)
$ git add .
$ git commit -m "测试 commitlint"
husky > commit-msg (node v10.13.0)nevergrowold
correct怎么读
input:
测试 commitlint
✖  message may not be empty [subject-empty]
✖  type may not be empty [type-empty]
✖  found 2 problems, 0 warningshusky > commit-msg hook failed (add --no-verify to bypass)$ git commit -m "feat():
添加commitlint"husky > commit-msg (node v10.13.0)
input: feat(): 添加commitlint ✔
没办法英文found 0 problems, 0 warnings[master 7a5bc00] feat(): 添加commitlint
4097 files changed, 219349 inrtions(+)
create mode fig.js
create mode 120000 node_modules/.bin/JSONStream
degreecreate mode 120000 node_modules/.bin/commitlint
create mode 120000 node_modules/.bin/conventional-commits-parr
........(这⾥第⼀次会有很多crete  mode 信息)
//最后执⾏git push 把修改推送到远端
$ git push
Counting objects: 3519, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3351/3351), done.
Writing objects: 100% (3519/3519), 2.21 MiB | 653.00 KiB/s, done.
Total 3519 (delta 741), reud 0 (delta 0)
点读机英语教材下载
remote: Resolving deltas: 100% (741/741), done.
:wei3715/RunLoop.git
9d89ab6..7a5bc00  master -> master
## commitlint
node_modules/
package-lock.json

本文发布于:2023-05-16 20:09:20,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/111054.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:规范   安装   信息   命令
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图