Skip to content

Commit 90ffcaf

Browse files
david-allisoncriticalAY
authored andcommitted
fix: installGitHook inside a worktree
In a worktree, `.git` is a file Fixes 20952 Assisted-by: Claude Opus 4.7 - all
1 parent 9e745d6 commit 90ffcaf

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

AnkiDroid/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,15 @@ play {
325325
}
326326

327327
// Install Git pre-commit hook for Ktlint
328+
// Resolve via git so worktrees (where `.git` is a file) are handled correctly.
329+
def gitHooksDir = providers.exec {
330+
workingDir = rootProject.rootDir
331+
commandLine "git", "rev-parse", "--git-path", "hooks"
332+
}.standardOutput.asText.map { rootProject.rootDir.toPath().resolve(it.trim()).toFile() }
333+
328334
tasks.register('installGitHook', Copy) {
329335
from new File(rootProject.rootDir, 'pre-commit')
330-
into { new File(rootProject.rootDir, '.git/hooks') }
336+
into gitHooksDir
331337
filePermissions {
332338
user {
333339
read = write = execute = true

0 commit comments

Comments
 (0)