Skip to content

Commit 4a89119

Browse files
authored
Merge pull request #88 from losadaem/feature/support_git_worktrees
feat: support git worktrees structure
2 parents 499a998 + 744fb6f commit 4a89119

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

simple-git-hooks.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ function getGitProjectRoot(directory=process.cwd()) {
6161
let content = fs.readFileSync(fullPath, { encoding: 'utf-8' })
6262
let match = /^gitdir: (.*)\s*$/.exec(content)
6363
if (match) {
64-
return path.normalize(match[1])
64+
let gitDir = match[1]
65+
let commonDir = path.join(gitDir, 'commondir');
66+
if (fs.existsSync(commonDir)) {
67+
commonDir = fs.readFileSync(commonDir, 'utf8').trim();
68+
return path.resolve(gitDir, commonDir)
69+
}
70+
return path.normalize(gitDir)
6571
}
6672
}
6773
return path.normalize(fullPath)

0 commit comments

Comments
 (0)