日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue 打印出git提交信息_规范git项目提交并自动生成项目commit log

發(fā)布時間:2025/3/21 vue 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue 打印出git提交信息_规范git项目提交并自动生成项目commit log 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
commit message 是開發(fā)的日常操作, 好的 log 不僅有助于他人 review, 還可以有效的輸出 CHANGELOG, 對項目的管理實際至關(guān)重要, 但是在平時工作時,只依賴大致的開發(fā)規(guī)范和自覺,很難形成一種普遍約束。而通過本文,對項目進行一些基礎(chǔ)配置,讓開發(fā)者在提交時可以自動對提交作出規(guī)范

1,項目效果

代碼提交


2,自動生成commit 日志

2,配置

依賴包

npm i vue-cli-plugin-commitlint commitizen commitlint conventional-changelog-cli husky -D

配置package.json

{"scripts": {"log": "conventional-changelog --config ./node_modules/vue-cli-plugin-commitlint/lib/log -i CHANGELOG.md -s -r 0","cz": "npm run log && git add . && git cz"},"husky": {"hooks": {"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"}},"config": {"commitizen": {"path": "./node_modules/vue-cli-plugin-commitlint/lib/cz"}} }

配置文件commitlint.config.js

module.exports = {extends: ['./node_modules/vue-cli-plugin-commitlint/lib/lint'] };

使用:

npm run cz # git add . && git commit -m 'feat:(xxx): xxx' npm run log # 生成 CHANGELOG

官方文檔:

vue-cli-plugin-commitlint?www.npmjs.com

3,各個包的作用解釋

根據(jù)上面的配置,已經(jīng)可以給項目配置提交的規(guī)范了。如果只是想應用,那么后面的各個包的功能解釋部分可以選看。

  • husky
  • commitizen
  • commitlint
  • conventional-changelog-cli
  • husky: git命令時,自定義指定一些動作

    // package.json {"husky": {"hooks": {"pre-commit": "npm test","pre-push": "npm test","...": "..."}} } // commit之前會走 test // push之前會走 test

    commitlint

    可以幫助我們 lint commit messages, 如果我們提交的不符合指向的規(guī)范, 直接拒絕提交, 比較狠.

    commitizen

    我們需要借助它提供的 git cz 命令替代我們的 git commit 命令, 幫助我們生成符合規(guī)范的 commit message

    conventional-changelog-cli

    根據(jù)git的metadata生成changelog

    所以,回看一下剛才的package.json

    {"scripts": {"log": "conventional-changelog --config ./node_modules/vue-cli-plugin-commitlint/lib/log -i CHANGELOG.md -s -r 0","cz": "npm run log && git add . && git cz"},"husky": {"hooks": {"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"}},"config": {"commitizen": {"path": "./node_modules/vue-cli-plugin-commitlint/lib/cz"}} }

    當輸入yarn cz時,

    0, 首先生成log

    1,走命令git cz。生成commit message

    2,husky檢查commit-msg: commitlint -E HUSKY_GIT_PARAMS

    3, 校驗完成后,自動提交

    總結(jié)

    以上是生活随笔為你收集整理的vue 打印出git提交信息_规范git项目提交并自动生成项目commit log的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。