Skip to content

Commit c24b418

Browse files
committed
build: support git worktrees in verifyCommit script
1 parent 11191bc commit c24b418

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/verifyCommit.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Invoked on the commit-msg git hook by simple-git-hooks.
22

33
import chalk from 'chalk'
4+
import { execSync } from 'node:child_process'
45
import { readFileSync } from 'node:fs'
56
import path from 'node:path'
67

7-
const msgPath = path.resolve('.git/COMMIT_EDITMSG')
8+
const gitDir = execSync('git rev-parse --git-dir', { encoding: 'utf-8' }).trim()
9+
const msgPath = path.resolve(gitDir, 'COMMIT_EDITMSG')
810
const msg = readFileSync(msgPath, 'utf-8').trim()
911

1012
const commitRE =

0 commit comments

Comments
 (0)