2023-10-23 14:03:29 +00:00
|
|
|
const msg = require('node:fs').readFileSync('.git/COMMIT_EDITMSG', 'utf-8').trim()
|
|
|
|
|
|
2022-11-14 02:41:05 +00:00
|
|
|
const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
|
2022-10-22 12:51:16 +00:00
|
|
|
const mergeRe = /^(Merge pull request|Merge branch)/
|
2022-06-09 04:50:04 +00:00
|
|
|
|
|
|
|
|
if (!commitRE.test(msg)) {
|
2022-09-29 09:32:29 +00:00
|
|
|
if (!mergeRe.test(msg)) {
|
2022-10-22 12:51:16 +00:00
|
|
|
console.log('git commit unpass')
|
|
|
|
|
console.error('git commit error, needs title(scope): desc')
|
2023-10-23 14:03:29 +00:00
|
|
|
// eslint-disable-next-line node/prefer-global/process
|
2022-10-22 12:51:16 +00:00
|
|
|
process.exit(1)
|
2022-06-09 04:50:04 +00:00
|
|
|
}
|
2023-10-23 14:03:29 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2022-10-22 12:51:16 +00:00
|
|
|
console.log('git commit pass')
|
2022-06-09 04:50:04 +00:00
|
|
|
}
|