-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-commit.ts
More file actions
20 lines (17 loc) · 837 Bytes
/
verify-commit.ts
File metadata and controls
20 lines (17 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import { log, setLogPrefix } from './packages/log'
const msgPath = path.resolve('.git/COMMIT_EDITMSG')
const msg = fs.readFileSync(msgPath, 'utf-8').trim()
const commitRE = /^(revert: )?(feat|fix|perf|refactor|test|types|docs|style|ci|build|release|workflow|dx|chore|wip|update|optimize)(\(.+\))?: .{1,50}/
if (!commitRE.test(msg)) {
setLogPrefix('[GIT COMMIT] ')
log.error('invalid commit message format')
log.warn('Proper commit message format is required for automated changelog generation.')
log.warn('Examples:')
log.info('feat: added some feature')
log.info('fix: fixed some error')
log.info('keywords: feat|fix|perf|refactor|test|types|docs|style|ci|build|release|workflow|dx|chore|wip|update|optimize')
process.exit(1)
}