Skip to content

Commit

Permalink
Merge pull request #88 from losadaem/feature/support_git_worktrees
Browse files Browse the repository at this point in the history
feat: support git worktrees structure
  • Loading branch information
toplenboren committed Jul 17, 2023
2 parents 499a998 + 744fb6f commit 4a89119
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion simple-git-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ function getGitProjectRoot(directory=process.cwd()) {
let content = fs.readFileSync(fullPath, { encoding: 'utf-8' })
let match = /^gitdir: (.*)\s*$/.exec(content)
if (match) {
return path.normalize(match[1])
let gitDir = match[1]
let commonDir = path.join(gitDir, 'commondir');
if (fs.existsSync(commonDir)) {
commonDir = fs.readFileSync(commonDir, 'utf8').trim();
return path.resolve(gitDir, commonDir)
}
return path.normalize(gitDir)
}
}
return path.normalize(fullPath)
Expand Down

0 comments on commit 4a89119

Please sign in to comment.