build: git钩子

This commit is contained in:
LOG1997
2025-12-10 00:10:33 +08:00
parent 80480213b8
commit 45e84db6d1
22 changed files with 121 additions and 10 deletions

View File

@@ -3,18 +3,18 @@ import fs from "fs";
const msg = fs.readFileSync(".git/COMMIT_EDITMSG", "utf-8").trim();
const commitRE =
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/;
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/;
const mergeRe = /^(Merge pull request|Merge branch)/;
if (!commitRE.test(msg)) {
if (!mergeRe.test(msg)) {
console.log("git commit信息校验不通过");
if (!mergeRe.test(msg)) {
console.log("git commit信息校验不通过");
console.error(`git commit的信息格式不对, 需要使用 title(scope): desc的格式
console.error(`git commit的信息格式不对, 需要使用 title(scope): desc的格式
比如 fix: xxbug
feat(test): add new
`);
process.exit(1);
}
process.exit(1);
}
} else {
console.log("git commit信息校验通过");
console.log("git commit信息校验通过");
}