Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义提交信息规范 #132

Open
Mrchangchang opened this issue May 11, 2022 · 2 comments
Open

自定义提交信息规范 #132

Mrchangchang opened this issue May 11, 2022 · 2 comments

Comments

@Mrchangchang
Copy link

  • fabric规定的提交信息规范和commitizen使用有些不一致,希望可以在项目中自定义提交规范。
  • 希望提供类似git cz 之类命令,方便用户规范提交信息
@wohaiwo
Copy link

wohaiwo commented Jul 21, 2022

参考 vue的 gitHooks commit-mgs 配置
https://github.com/vuejs/vue/blob/main/package.json

@EricWong1994
Copy link

我自己重写的commit-msg,同时安装了下面这两个依赖

"os-locale": "^5.0.0",
"chalk": "^4.1.1"
#!/usr/bin/env node
var chalk = require('chalk');
var osLocale = require('os-locale');
const msg = require('fs').readFileSync(process.argv[2], 'utf-8').trim(); 
var commitRE = /^(((\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f\ude80-\udeff])|[\u2600-\u2B55]) )?(revert: )?(feat|fix|docs|style|refactor|perf|workflow|build|ci|typos|chore|test|types|wip|release|dep|locale|conflict|font|delete|stash)(\(.+\))?: .{1,50}/;

if (!commitRE.test(msg)) {
  osLocale().then(function (locale) {
    if (locale === 'zh-CN') {
      console.error("  ".concat(chalk.bgRed.white(' ERROR '), " ").concat(chalk.red("\u63D0\u4EA4\u65E5\u5FD7\u4E0D\u7B26\u5408\u89C4\u8303"), "\n\n").concat(chalk.red("  \u5408\u6CD5\u7684\u63D0\u4EA4\u65E5\u5FD7\u683C\u5F0F\u5982\u4E0B(emoji \u548C \u6A21\u5757\u53EF\u9009\u586B)\uFF1A\n\n"), "    \n        ").concat(chalk.green("[<emoji>] [revert: ?]<type>[(scope)?]: <message>\n"), "\n        ").concat(chalk.green("\uD83D\uDCA5 feat(\u6A21\u5757): \u6DFB\u52A0\u4E86\u4E2A\u5F88\u68D2\u7684\u529F\u80FD"), "\n        ").concat(chalk.green("\uD83D\uDC1B fix(\u6A21\u5757): \u4FEE\u590D\u4E86\u4E00\u4E9B bug"), "\n        ").concat(chalk.green("\uD83D\uDCDD docs(\u6A21\u5757): \u66F4\u65B0\u4E86\u4E00\u4E0B\u6587\u6863"), "\n        ").concat(chalk.green("\uD83C\uDF37 style(\u6A21\u5757): \u4FEE\u6539\u4E86\u4E00\u4E0B\u6837\u5F0F"), "\n        ").concat(chalk.green("\uD83C\uDFF0 chore(\u6A21\u5757): \u5BF9\u811A\u624B\u67B6\u505A\u4E86\u4E9B\u66F4\u6539"), "\n        ").concat(chalk.green("\uD83C\uDF10 locale(\u6A21\u5757): \u4E3A\u56FD\u9645\u5316\u505A\u4E86\u5FAE\u5C0F\u7684\u8D21\u732E\n"), "\n        ").concat(chalk.green("\u5176\u4ED6\u63D0\u4EA4\u7C7B\u578B: refactor, perf, workflow, build, ci, typos, test, types, wip, release, dep, conflict, font, delete, stash\n"), "\n        ").concat(chalk.red("See .github/commit-convention.md for more details.\n")));
    }
    else {
      console.error("  ".concat(chalk.bgRed.white(' ERROR '), " ").concat(chalk.red("invalid commit message format."), "\n\n").concat(chalk.red("  Proper commit message format is required for automated changelog generation. Examples:\n\n"), "    \n        ").concat(chalk.green("[<emoji>] [revert: ?]<type>[(scope)?]: <message>\n"), "\n        ").concat(chalk.green("\uD83D\uDCA5 feat(compiler): add 'comments' option"), "\n        ").concat(chalk.green("\uD83D\uDC1B fix(compiler): fix some bug"), "\n        ").concat(chalk.green("\uD83D\uDCDD docs(compiler): add some docs"), "\n        ").concat(chalk.green("\uD83C\uDF37 style(compiler): better styles"), "\n        ").concat(chalk.green("\uD83C\uDFF0 chore(compiler): Made some changes to the scaffolding"), "\n        ").concat(chalk.green("\uD83C\uDF10 locale(compiler): Made a small contribution to internationalization\n"), "\n        ").concat(chalk.green("Other commit types: refactor, perf, workflow, build, ci, typos, test, types, wip, release, dep, conflict, font, delete, stash\n"), "\n        ").concat(chalk.red("See .github/commit-convention.md for more details.\n")));
    }
    process.exit(1);
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants