尊龙凯时人生就是搏

Gitlabѧϰ֮ÆóÒµ³£ÓõÄһЩgit¹æ·¶

Ë×»°Ëµ£¬Ã»ÓйæÔò²»¿ÉÖÜÔ⣬ÎÒÃǵÄgitÒ²ÐèÒª¹æ·¶ ¡£

ÏÂÃæÏÈÈÝÒ»ÏÂÆóÒµ³£ÓõÄһЩ¹æ·¶ ¡£

·ÖÖ§ÖÎÀí¹æ·¶

·ÖÖ§ÃüÃû²»¿ÉǧÆæ°Ù¹Ö£¬±ØÐèÓÐͳһµÄÃüÃû·½·¨ ¡£Ö÷ÒªÓÐÒÔϼ¸ÖÖ£º

·ÖÖ§ÖÎÀí ÃüÃû¹æ·¶ Ú¹ÊÍ
master Ö÷·ÖÖ§ master Îȹ̰æÌìÖ°Ö§£¬ÉÏÏßÍê³É»Ø¹éºóºó£¬ÓÉÏîÄ¿ÊÖÒÕÈÏÕæÈË´Ó release ·ÖÖ§ºÏ²¢½øÀ´£¬²¢´ò tag
test ²âÊÔ·ÖÖ§ test/yyyyMMdd_ ¹¦Ð§Ãû³ÆʾÀý£ºtest/20220426_blog ²âÊÔְԱʹÓ÷ÖÖ§£¬²âÊÔʱ´Ó feature ·ÖÖ§ºÏ²¢½øÀ´
feature ¹¦Ð§¿ª·¢·ÖÖ§ feature/yyyyMMdd_ ¹¦Ð§Ãû³Æ_ÈÏÕæְԱʾÀý£ºfeature/20220426_blog_xiumubai й¦Ð§¿ª·¢Ê¹Ó÷ÖÖ§£¬»ùÓÚmaster½¨Éè
fix bugÐÞ¸´·ÖÖ§ fix/yyyyMMdd_ ¹¦Ð§Ãû³Æ_ÈÏÕæְԱʾÀý£ºfix/20220426_blog_xiumubai ½ôÆÈÏßÉÏbugÐÞ¸´Ê¹Ó÷ÖÖ§£¬»ùÓÚmaster½¨Éè
release ÉÏÏß·ÖÖ§ release/°æ±¾ºÅʾÀý£ºrelease/0.1.0 ÓÃÓÚÉÏÏߵķÖÖ§£¬»ùÓÚ master ½¨É裬±ØÐè¶ÔÒª²¢ÈëµÄ feature ·ÖÖ§¾ÙÐÐ Code review ºó£¬²Å¿É²¢ÈëÉÏÏß

°æ±¾ºÅÖÎÀí¹æ·¶

µ±ÎÒÃÇÉÏÏßµÄʱ¼ä£¬ÐèÒª¸ø°æ±¾ºÅ´òtag£¬ÏÂÃæÊÇ°æ±¾ºÅ¹æ·¶£º

ÏîÄ¿ÉÏÏßrelease·ÖÖ§½¨Éè½ç˵£º
  
µÚÒ»¸öÊý×ÖÊÇÖ÷°æ±¾¡£µÚ¶þ¸öÊý×ÖÊǴΰ汾¡£µÚÈý¸öÊý×ÖÊDz¹¶¡°æ±¾(hotfix ÀàµÄ¸üÐÂ)¡£

Ö÷°æ±¾£ºº¬ÓÐÆÆËðÐÔ¸üС¢´óµ÷½âµÈ¡£ ÀýÈ磺1.1.0 > 2.0.0

´Î°æ±¾£ºÔöÌíй¦Ð§ÌØÕ÷¡£ÀýÈ磺1.1.0 > 1.2.0

²¹¶¡°æ±¾£ºÐÞ¸´ÎÊÌâµÈ¡£ÀýÈ磺1.1.0 > 1.1.1

µÇ¼ºó¸´ÖÆ

ÏÂͼÊÇÒ»¸öΧÈÆgit¹æ·¶À´µÄ¿ª·¢Á÷³Ìͼ£º

Ìá½»ÐÅÏ¢¹æ·¶

×îºóÊÇcommitµÄʱ¼ä£¬ÐèÒª¶ÔcommitÐÅÏ¢¹æ·¶£¬±ØÐèÒª¼Óǰ׺

ǰ׺ Ú¹ÊÍ
feat й¦Ð§
fix ÐÞ¸´
docs Îĵµ±ä»»
style ´úÂëÃûÌÃ
refactor Öع¹
perf ÐÔÄÜÓÅ»¯
test ÔöÌí²âÊÔ
revert »ØÍË
build ´ò°ü
chore ¹¹½¨Àú³Ì»ò¸¨Öú¹¤¾ßµÄ±ä»»

ÏÂͼÊÇvue3Ô´ÂëµÄÌá½»ÐÅÏ¢¹æ·¶£º

ÏÂÃæÎÒÃǾÍÏÖʵ²Ù×÷һϣ¬ÈôÊÇͨ¹ýhusky+commitlint¼¯³ÉÒ»¸öͳһ¹æ·¶µÄgit commitÐÅÏ¢ ¡£

ÉèÖà git Ìá½»µÄУÑé¹³×Ó

husky: gitÌύʱ´¥·¢hooks

commitlint: ¶ÔÌá½»µÄÄÚÈÝ×ö¹æ·¶Ð£Ñé husky£¬Ö÷Òª¶Ôpre-commitºÍcommit-msg¹³×Ó×öУÑé ¡£

# ×°ÖÃhusky
yarn add husky -D
# ³õʼ»¯huskyÉèÖã¬ÔÚ¸ùĿ¼ÐÂÔö.huskyÉèÖÃÎļþ¡£³õʼ»¯ÉèÖÃpre-commit
npx husky-init 
# ÁíÍâÐÂÔöÒ»¸öhooks£¬commit-msg
npx husky add .husky/commit-msg

µÇ¼ºó¸´ÖÆ

Ŀ¼½á¹¹ÊÇÏÂÃæÕâÑù×ӵģº

ÔÚcommit-msgÎļþÖÐÌí¼Ó npm run commitlint

ÔÚpre-commitÎļþÖÐÓиönpm run testÎÒÃÇÏÈ×¢Ê͵ô£¬²»È»»á±¨´í ¡£

×°ÖÃcommitlint

# Ìí¼ÓÒÀÀµÎļþ
yarn add @commitlint/config-conventional @commitlint/cli -D

µÇ¼ºó¸´ÖÆ

Ìí¼ÓÉèÖÃÎļþ£¬Ð½¨commitlint.config.js£¬È»ºóÌí¼ÓÏÂÃæµÄ´úÂ룺

module.exports = {
  extends: ['@commitlint/config-conventional'],
  // УÑé¹æÔò
  rules: {
    'type-enum': [
      2,
      'always',
      [
        'feat',
        'fix',
        'docs',
        'style',
        'refactor',
        'perf',
        'test',
        'chore',
        'revert',
        'build',
      ],
    ],
    'type-case': [0],
    'type-empty': [0],
    'scope-empty': [0],
    'scope-case': [0],
    'subject-full-stop': [0, 'never'],
    'subject-case': [0, 'never'],
    'header-max-length': [0, 'always', 72],
  },
}

µÇ¼ºó¸´ÖÆ

ÉèÖÃscripts

ÓÉÓÚÎÒÃÇÐèÒªÔËÐÐnpm run commitlint£¬ÒÔÊÇÐèÒªÔÚpackage.jsonÎļþÖÐÌí¼ÓÈçÏ´úÂ룺

# ÔÚscripsÖÐÌí¼ÓÏÂÃæµÄ´úÂë
{
"scripts": {
    "commitlint": "commitlint --config commitlint.config.js -e -V"
  },
}

µÇ¼ºó¸´ÖÆ

ÉèÖÿ¢Ê£¬ÏÖÔÚµ±ÎÒÃÇÌîдcommitÐÅÏ¢µÄʱ¼ä£¬Ç°Ãæ¾ÍÐèÒª´ø×ÅÏÂÃæµÄsubject

'feat',
'fix',
'docs',
'style',
'refactor',
'perf',
'test',
'chore',
'revert',
'build',

µÇ¼ºó¸´ÖÆ

ºÃ±È£ºgit commit -m “feat: test”,×¢ÖØfeat:ºóÃæÓиö¿Õ¸ñ

ÎÒÃÇÀ´Ð´Ò»¸ö¹ýʧµÄÀ´²âÊÔһϣº

Gitlabѧϰ֮ÆóÒµ³£ÓõÄһЩgit¹æ·¶

ÌáÐÑsubjectÊÇ¿ÕµÄ ¡£

ʹÓÃ׼ȷµÄÌá½»·½·¨£¬Ìá½»ÀÖ³ÉÁË

Gitlabѧϰ֮ÆóÒµ³£ÓõÄһЩgit¹æ·¶

ʹÓà commitizen ×ögit¹æ·¶»¯Ìá½»

ÓÉÓÚÌí¼ÓÁËcommitlintÑéÖ¤£¬¹ØÓÚ²»ÊìϤÌá½»¹æ·¶µÄÐÂÊÖͬÑâ»áÓÐÒ»¶¨Ó°Ï죬¿ÉÒÔÌí¼Ó commitizen ¹¤¾ß£¬ÊÖ¶¯Éúªϰ·¶»¯commit ¡£

CommitizenÊÇÒ»¸öÃûÌû¯commit messageµÄ¹¤¾ß ¡£

# ¹¤¾ß×°ÖÃ
yarn add -D commitizen

µÇ¼ºó¸´ÖÆ

ʹÓÃcz-conventional-changelog

×°Öù¤¾ß

yarn add cz-conventional-changelog -D

µÇ¼ºó¸´ÖÆ

ÉèÖÃÏÂÁî

"script": {
    "commit": "cz"
}

µÇ¼ºó¸´ÖÆ

ÔÚpackage.json ÖÐÌí¼Ó½ç˵commitizenʹÓùæÔò£¬

{
	"config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  },
}

µÇ¼ºó¸´ÖÆ

µ±Ö´ÐÐgit commitµÄʱ¼ä£¬¾Í¿ÉÒÔÌáÐÑÎÒÃÇÌîд´úÂë¹æÔòÁË

×Ô½ç˵ commitizen ¹æÔò

ʹÓà cz-customizable ¹¤¾ß

# ×°ÖÃÒÀÀµ
yarn add cz-customizable -D

µÇ¼ºó¸´ÖÆ

ÉèÖÃÏÂÁî

"script": {
    "commit": "git-cz"
}

µÇ¼ºó¸´ÖÆ

ÔÚpackage.json ÖÐÌí¼Ó×Ô½ç˵commitizen£¬Ê¹ÓÃgit-czÖ´ÐÐgit commitÏÂÁî

"config": {
    "commitizen": {
        "path": "./node_modules/cz-customizable"
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚ¸ùĿ¼½¨ÉèµÄ.cz-config.js, ×Ô½ç˵commitÌáÐÑÄÚÈÝ

module.exports = {
  types: [
    { value: 'feat', name: 'feat:     й¦Ð§' },
    { value: 'fix', name: '?fix:      ÐÞ¸´' },
    { value: 'docs', name: '️docs:     Îĵµ±ä»»' },
    { value: 'style', name: '?style:    ´úÂëÃûÌÃ(²»Ó°Ïì´úÂëÔËÐеı任)' },
    {
      value: 'refactor',
      name: '️refactor: Öع¹(¼È²»ÊÇÔöÌífeature£¬Ò²²»ÊÇÐÞ¸´bug)'
    },
    { value: 'perf', name: '️perf:     ÐÔÄÜÓÅ»¯' },
    { value: 'test', name: 'test:     ÔöÌí²âÊÔ' },
    { value: 'chore', name: '?chore:    ¹¹½¨Àú³Ì»ò¸¨Öú¹¤¾ßµÄ±ä»»' },
    { value: 'revert', name: '⏪️revert:   »ØÍË' },
    { value: 'build', name: '?️build:    ´ò°ü' },
    { value: 'ci', name: '?CI:   related changes' }
  ],
  // override the messages, defaults are as follows
  messages: {
    type: 'ÇëÑ¡ÔñÌá½»ÀàÐÍ(±ØÑ¡):',
    // scope: 'ÇëÊäÈëÎļþÐ޸ĹæÄ£(¿ÉÑ¡):',
    customScope: 'ÇëÊäÈëÐ޸ĹæÄ£(¿ÉÑ¡):',
    subject: 'Çë¼òÒªÐÎòÌá½»(±ØÌî):',
    // body: 'ÇëÊäÈëÏêϸÐÎò(¿ÉÑ¡£¬´ýÓÅ»¯È¥³ý£¬Ìø¹ý¼´¿É):',
    // breaking: 'List any BREAKING CHANGES (optional):n',
    footer: 'ÇëÊäÈëÒª¹Ø±ÕµÄissue(´ýÓÅ»¯È¥³ý£¬Ìø¹ý¼´¿É):',
    confirmCommit: 'È·ÈÏʹÓÃÒÔÉÏÐÅÏ¢Ìá½»£¿(y/n/e/h)'
  },
  // used if allowCustomScopes is true
  allowCustomScopes: true,
  // allowBreakingChanges: ['feat', 'fix'],
  skipQuestions: ['body', 'footer'],
  // limit subject length, commitlintĬÈÏÊÇ72
  subjectLimit: 72
}

µÇ¼ºó¸´ÖÆ

µ±ÎÒÃÇÌá½»½ÓÂëµÄʱ¼ä£¬ÐèÒªÏÈgit add .£¬È»ºóÖ´ÐÐnpm run commit,¾Í¿ÉÒÔƾ֤ÏìÓ¦µÄÌáÐÑÌîдcommitÐÅÏ¢ ÁË£¬ÈçÏÂͼËùʾ£º

Gitlabѧϰ֮ÆóÒµ³£ÓõÄһЩgit¹æ·¶

£¨Ñ§Ï°ÊÓƵ·ÖÏí£º±à³Ì»ù´¡ÊÓƵ£©

ÒÔÉϾÍÊÇGitlabѧϰ֮ÆóÒµ³£ÓõÄһЩgit¹æ·¶µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼ ¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý ¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ