鍓嶇涔嬭矾锛氱敤 Angular 瑙勮寖鏉ョ害鏉熷洟闃?git 鎻愪氦

Posted 鎺橀噾寮€鍙戣€呯ぞ鍖?/a>

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鍓嶇涔嬭矾锛氱敤 Angular 瑙勮寖鏉ョ害鏉熷洟闃?git 鎻愪氦相关的知识,希望对你有一定的参考价值。

鏈枃鍑鸿嚜銆屾帢閲戠ぞ鍖恒€嶏紝娆㈣繋鎴炽€岄槄璇诲師鏂囥€嶉摼鎺ュ拰浣滆€呰繘琛屾妧鏈氦娴?馃帀馃帀

CommitMsg

git 鎻愪氦瑙勮寖

鑳屾櫙

鍥㈤槦鍗忎綔寮€鍙戯紝 git 浣滀负涓€涓紑婧愮殑鍒嗗竷寮忕増鏈帶鍒剁郴缁燂紝淇ㄧ劧鎴愪负褰撲笅鏈€鍙楁鐨勯」鐩唬鐮佺増鏈鐞嗗伐鍏凤紝 鍗虫槸鍥㈤槦锛屽氨瑕佹湁涓€瀹氱殑瑙勭煩锛岃鑼冿紝杩欐牱鎵嶈兘鏇村ソ鐨勫彂鎸ュ洟闃熸晥鐜囥€傜啛鎮?git 鐨勫皬浼欎即閮界煡閬擄紝姣忔鎻愪氦浠g爜锛?閮借鍐?Commit message锛堟彁浜よ鏄庯級锛屽惁鍒欏氨涓嶅厑璁告彁浜わ紝鑷充簬鎻愪氦鐨勪俊鎭?git 骞舵病鏈夎繘琛岀害鏉燂紝浠ヨ嚦浜庯紝 鎻愪氦涓婃潵鐨勮鏄庢槸浜旇姳鍏棬锛岀敱姝ょぞ鍖哄嚭鐜颁簡澶氱鍐欐硶瑙勮寖锛屽叾涓?span class="mq-13"> Angular 瑙勮寖 鏄洰鍓嶆渶涓哄箍娉涚殑鍐欐硶锛屾瘮杈冨悎鐞嗗拰绯荤粺鍖栥€傛湰鏂囧氨鏉ヨ涓€璁蹭袱绉嶄娇鐢?Angular 瑙勮寖鐨勬柟娉曘€?/p>

娉曚竴锛屽熀浜庨」鐩€氳繃 hooks 瑙﹀彂锛堟垜鍙稿洟闃熺敤鐨勬鏂规硶锛?/h4>

杩欑鏂规硶鐨勫ソ澶勬槸锛屼换浣曚汉鍙鎯冲線鏈」鐩彁浜?commit锛屽氨蹇呴』鎸夌収瑙勮寖锛屽惁鍒欎笉鐒舵彁浜ゃ€?/p>

  1. 瀹夎鎵€闇€渚濊禆锛?nbsp;npm i--save-dev husky chalk锛?/span>

  2. 鍦ㄩ」鐩殑鏍圭洰褰曟柊寤轰竴涓枃浠跺す .github 锛堝悕瀛楅殢鎰忥級锛岃繖涓枃浠跺す涓撻棬鐢ㄦ潵瀛樻斁 github 鐩稿叧鐨勪笢瑗匡紱

  3. 鍦ㄤ笂涓€姝ョ殑鏂囦欢澶逛腑鏂板缓 node 鑴氭湰鏂囦欢 verifyCommitMsg 锛堝悕瀛楅殢鎰忥級锛?/span>

  4. 鍦ㄤ笂涓€姝ョ殑鑴氭湰鏂囦欢涓啓鍏ヤ竴涓嬩唬鐮侊細

 
   
   
 
  1. #!/bin/env node

  2. const chalk = require('chalk');

  3. const msgPath = process.env.HUSKY_GIT_PARAMS;

  4. if (!msgPath) {

  5. console.error(chalk.red(`process.env.HUSKY_GIT_PARAMS can't be ${msgPath},please check`));

  6. process.exit(1);

  7. }

  8. console.log('HUSKY_GIT_PARAMS: ', msgPath);

  9. const msg = require('fs')

  10. .readFileSync(msgPath, 'utf-8')

  11. .trim();

  12. console.log(msg);

  13. const commitRE = /^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types)(\(.+\))?: .{1,50}/;

  14. if (!commitRE.test(msg)) {

  15. console.log();

  16. console.error(

  17. ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(`invalid commit message format.`)}\n\n` +

  18. chalk.red(

  19. ` Proper commit message format is required for automated changelog generation. Examples:\n\n`

  20. ) +

  21. ` ${chalk.green(`feat(compiler): add 'comments' option`)}\n` +

  22. ` ${chalk.green(`fix(v-model): handle events on blur (close ###28)`)}\n\n` +

  23. chalk.red(` See .github/COMMIT_CONVENTION.md for more details.\n`)

  24. // chalk.red(` You can also use ${chalk.cyan(`npm run commit`)} to interactively generate a commit message.\n`)

  25. );

  26. process.exit(1);

  27. }

鍦?nbsp;package.json 澧炲姞/淇敼 hooks锛屽涓嬶細

 
   
   
 
  1. ...

  2. "husky": {

  3. "hooks": {

  4. "commit-msg": "node .github/verifyCommitMsg"

  5. }

  6. },

  7. ...

杩欐牱灏卞仛鍒颁簡姣忔鎻愪氦閮戒細妫€鏌?commit 淇℃伅浜嗭紝褰撲笉绗﹀悎瑙勮寖鏃讹紝浼氱粰鍑烘彁绀恒€備緥濡傦細

娉曚簩锛屽熀浜?npm 渚濊禆鎻掍欢

杩欑鏂规硶鐨勫ソ澶勬槸锛屾彁浜ゆ瘮杈冧汉鎬у寲銆?/p>

  1. 鍏ㄥ眬瀹夎渚濊禆锛?nbsp;npm i-g commitizen

  2. 鍒濆鍖栭€傞厤鍣紝 commitizen init cz-conventional-changelog--save-dev--save-exact

  3. 鐢?nbsp;git cz 鍛戒护 浠f浛 git commit

渚嬪锛?/p>

===馃馃 鏂囦腑涓嶈冻锛屾杩庢寚姝?馃お馃お===


以上是关于鍓嶇涔嬭矾锛氱敤 Angular 瑙勮寖鏉ョ害鏉熷洟闃?git 鎻愪氦的主要内容,如果未能解决你的问题,请参考以下文章

docker瀛︿範涔嬭矾

Python瀛︿範涔嬭矾鈥?018/7/11

鑵捐 Git 瑙勮寖鍑虹倝锛屽啓缁欏紑鍙戣€呯殑 Git 鎸囧崡!

娴嬪紑涔嬭矾涓€鐧鹃浂鍥涳細jquery鎿嶄綔鏍峰紡

鎴戠殑鍏ㄦ爤涔嬭矾-C璇█鍩虹涔婥绋嬪簭杩愯娴佺▼

鏍规嵁 Promise/A+ 鍜?ES6 瑙勮寖锛屽疄鐜?Promise 婧愮爜锛堥檮璇︾粏娉ㄩ噴鍜屾祴璇曪級