diff --git a/.husky/commit-msg b/.husky/commit-msg index 28e67e9..70643b1 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,5 @@ if [ ! -w "${HOME:-/root}" ]; then + export HOME=/tmp export XDG_CACHE_HOME="${XDG_CACHE_HOME:-/tmp}" export COREPACK_HOME="${COREPACK_HOME:-/tmp/corepack}" fi diff --git a/.husky/pre-commit b/.husky/pre-commit index 882a730..aedcdfb 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,5 @@ if [ ! -w "${HOME:-/root}" ]; then + export HOME=/tmp export XDG_CACHE_HOME="${XDG_CACHE_HOME:-/tmp}" export COREPACK_HOME="${COREPACK_HOME:-/tmp/corepack}" fi diff --git a/commitlint.config.cjs b/commitlint.config.cjs index d2ef1bd..afd5361 100644 --- a/commitlint.config.cjs +++ b/commitlint.config.cjs @@ -8,6 +8,23 @@ module.exports = { // 继承的规则 extends: ['@commitlint/config-conventional'], + // 自定义插件规则 + plugins: [ + { + rules: { + 'subject-chinese': (parsed) => { + const subject = String(parsed?.subject ?? '').trim() + if (!subject) { + return [false, '冒号后面的内容(subject)不能为空'] + } + + // 要求 subject 以中文字符开头(允许后续包含数字/空格/标点/英文缩写) + const startsWithChinese = /^[\u4E00-\u9FFF]/u.test(subject) + return [startsWithChinese, '冒号后面的内容(subject)必须以中文开头'] + } + } + } + ], // 自定义规则 rules: { // 提交类型枚举,git提交type必须是以下类型 @@ -29,6 +46,7 @@ module.exports = { 'wip' // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例) ] ], + 'subject-chinese': [2, 'always'], 'subject-case': [0] // subject大小写不做校验 },