commitizen(git commit format)
发布日期:2022-02-14 23:02:42 浏览次数:19 分类:技术文章

本文共 2171 字,大约阅读时间需要 7 分钟。

  • Install
    • commitizen install
    sudo npm install -g commitizen
    • first project config

      • config
      cd Path_Git_Porject# base config commitizen init cz-conventional-changelog --save --save-exact #  config with format check npm i -D husky @commitlint/config-conventional @commitlint/cli
      • if config with format check, need to config js and husky
        • create commitlint.config.js(with same path of package.json)
        echo 'module.exports = {extends: ["@commitlint/config-conventional"]};' > ./commitlint.config.js
        • husky(add package.json)
        ..., 	"husky": {
        "hooks": {
        "commit-msg": "commitlint -e $GIT_PARAMS" } }
    • second project config

    cd Path_Git_Porjectcommitizen init cz-conventional-changelog --force
    • use
    git cz relpace git commit
    • use by interactive mode
    1.Select the type of change that you're committing 选择改动类型 (
    )2.What is the scope of this change (e.g. component or file name)? 填写改动范围 (
    )3.Write a short, imperative tense description of the change: 写一个精简的描述 (
    )4.Provide a longer description of the change: (press enter to skip) 对于改动写一段长描述 ()5.Are there any breaking changes? (y/n) 是破坏性修改吗?默认n (
    )6.Does this change affect any openreve issues? (y/n) 改动修复了哪个问题?默认n (
    )
    • commit message format:husky will use commitlint check message format
    (
    ):
  • Install ERROR or WARN
  • Fromat
    • type:必填项,用于指定commit的类型
      • feat:增加新功能 (主要type)
      • fix: 修复Bug (主要type)
      • docs:只改动了文档相关的内容 (特殊type)
      • style:不影响代码含义的改动,例如去掉空格、改变缩进、增删分号 (特殊type)
      • build:构造工具的或者外部依赖的改动,例如webpack,npm (特殊type)
      • refactor:代码重构时使用 (特殊type)
      • revert:执行git revert打印的message (特殊type)
    • scope:必填项,用于描述改动的范围,格式为项目名/模块名:如果一次commit修改多个模块,建议拆分成多次commit,以便更好追踪和维护
    • Body:详细描述,主要描述改动之前的情况及修改动机,对于小的修改不作要求,但是重大需求、更新等必须添加body来作说明
    • break changes:是否产生了破坏性修改,涉及break changes的改动必须指明该项,类似版本升级、接口参数减少、接口删除、迁移等
    • affect issues:是否影响了某个问题。例如我们使用jira时,我们在commit message中可以填写其影响的JIRA_ID,若要开启该功能需要先打通jira与gitlab
  • git config file
    • .gitconfig:the config of current user
      • Windows:C:\Users\administrator.gitconfig
      • Linux: ~/.gitconfig
    • .git:the config of current project

转载地址:https://blog.csdn.net/fish2009122/article/details/103416926 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:StreamSet操作
下一篇:【转载】Python假设检验

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月07日 07时25分12秒