Merge pull request #1982 from davotoula/fix-for-githooks-in-git-worktree

Handle git worktree where .git is a file, not a directory
This commit is contained in:
Vitor Pamplona
2026-03-28 12:08:28 -04:00
committed by GitHub
+10 -1
View File
@@ -62,9 +62,18 @@ subprojects {
}
tasks.register('installGitHook', Copy) {
def dotGit = new File(rootProject.rootDir, '.git')
def hooksDir
if (dotGit.isFile()) {
// Git worktree: .git is a file with "gitdir: <path>"
def gitDir = new File(dotGit.text.trim().replace('gitdir: ', ''))
hooksDir = new File(gitDir, 'hooks')
} else {
hooksDir = new File(dotGit, 'hooks')
}
from new File(rootProject.rootDir, '.git-hooks/pre-commit')
from new File(rootProject.rootDir, '.git-hooks/pre-push')
into { new File(rootProject.rootDir, '.git/hooks') }
into { hooksDir }
filePermissions { unix(0777) }
}
tasks.getByPath(':amethyst:preBuild').dependsOn installGitHook