Closed SuiKaSan closed 8 months ago
git commit -m '⚡ pref: test'
一样提交不了
/**
* @type {import('cz-git').UserConfig}
* */
module.exports = {
ignores: [(commit) => commit.includes('init')],
extends: ['@commitlint/config-conventional'],
rules: {
'body-leading-blank': [2, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [2, 'always', 50],
'subject-empty': [2, 'always'],
'type-empty': [2, 'always'],
'subject-case': [0],
'type-enum': [2, 'always', ['✨ feat', '🐞 fix', '📝 docs', '💄 style', '♻️ refactor', '⚡️ perf', '✅ test', '📦️ build', '🎡 ci', '🔨 revert', '⏪️ chore']],
},
prompt: {
alias: {
f: 'docs: fix typos',
r: 'docs: update README',
s: 'style: update code format',
b: 'build: bump dependencies',
c: 'chore: update config',
},
customScopesAlign: 'top',
defaultScope: ['custom'],
scopes: ['scene', 'room', 'docker', 'setting', 'pilot feature', 'matter', 'cast', 'security', 'etc'],
allowCustomScopes: true,
allowEmptyScopes: true,
allowEmptyIssuePrefixs: true,
allowCustomIssuePrefixs: true,
messages: {
type: '选择你要提交的类型 :',
scope: '选择一个提交范围(可选):',
customScope: '请输入自定义的提交范围 :',
subject: '填写简短精炼的变更描述 :\n',
body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n',
confirmCommit: '是否提交或修改commit ?',
},
types: [
{ value: 'feat', name: 'feat: ✨ 新增功能 | A new feature', emoji: '✨' },
{ value: 'fix', name: 'fix: 🐞 修复缺陷 | A bug fix', emoji: '🐞' },
{
value: 'docs',
name: 'docs: 📝 文档更新 | Documentation only changes',
emoji: '📝',
},
{
value: 'style',
name: 'style: 💄 代码格式 | Changes that do not affect the meaning of the code',
emoji: '💄',
},
{
value: 'refactor',
name: 'refactor: ♻️ 代码重构 | A code change that neither fixes a bug nor adds a feature',
emoji: '♻️',
},
{
value: 'perf',
name: 'perf: ⚡️ 性能提升 | A code change that improves performance',
emoji: '⚡️',
},
{
value: 'test',
name: 'test: ✅ 测试相关 | Adding missing tests or correcting existing tests',
emoji: '✅',
},
{
value: 'build',
name: 'build: 📦️ 构建相关 | Changes that affect the build system or external dependencies',
emoji: '📦️',
},
{
value: 'ci',
name: 'ci: 🎡 持续集成 | Changes to our CI configuration files and scripts',
emoji: '🎡',
},
{ value: 'revert', name: 'revert: 🔨 回退代码 | Revert to a commit', emoji: '🔨' },
{
value: 'chore',
name: 'chore: ⏪️ 其他修改 | Other changes that do not modify src or test files',
emoji: '⏪️',
},
],
useEmoji: true,
emojiAlign: 'left',
themeColorCode: '',
upperCaseSubject: false,
skipQuestions: ['breaking', 'footer', 'footerPrefix'],
breaklineNumber: 100,
breaklineChar: '|',
confirmColorize: true,
minSubjectLength: 0,
scopeOverrides: undefined,
defaultBody: '',
defaultIssues: '',
defaultSubject: '',
},
};
https://github.com/Zhengqbbb/cz-git/issues/151#issuecomment-1865393397
可是按照这个设置,将这两条规则设置为always,不符合要求的commit-msg也会通过校验,@Zhengqbbb
是的,所以我后面还是改为将emoji放在中间了,毕竟也不是特别大的问题。
是因为 Emoji 放在第一位并不是传统的约定式提交协议规定,所以 cz-git
默认是放在描述头部避免与协议冲突,哪怕是其他 commitlint
校验工具也不支持Emoji字符放在第一位。
所以关键是找到非传统的 commitlint
校验规则:例如 https://github.com/ccnnde/commitlint-config-git-commit-emoji
extends
中的 @commitlint/config-conventional
替换为 git-commit-emoji
npm remove @commitlint/config-conventional
npm install -D commitlint-config-git-commit-emoji
当然也可以不引入配置依赖,手动参照这份配置文件进行配置
✅ Checklist
📄 System Info
🔎 Description
我已看过bug单 #114 ,按照其中提供的例子进行修改,依然无法通过校验。
请问有人遇到这种情况吗? 这是我的配置文件
校验后报错依旧:![image](https://github.com/Zhengqbbb/cz-git/assets/44567811/870a46a4-9e3a-4d42-abd2-641393d3edb8)
🔗 Reproduction link / repo:
No response