From 20b8a6973cebca6b1eb18ce5565b6ec6e0d57d0c Mon Sep 17 00:00:00 2001 From: Daniel Tang Date: Sun, 19 Mar 2023 02:21:24 -0400 Subject: [PATCH] Support git worktrees --- team-props/git-hooks.gradle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/team-props/git-hooks.gradle b/team-props/git-hooks.gradle index 41aae5d0b..1c80c43f6 100644 --- a/team-props/git-hooks.gradle +++ b/team-props/git-hooks.gradle @@ -3,13 +3,15 @@ static def isLinuxOrMacOs() { return osName.contains('linux') || osName.contains('mac os') || osName.contains('macos') } +def gitHooksDir = 'git rev-parse --path-format=absolute --git-path hooks'.execute().text.trim() + task copyGitHooks(type: Copy) { description 'Copies the git hooks from team-props/git-hooks to the .git folder.' from("${rootDir}/team-props/git-hooks/") { include '**/*.sh' rename '(.*).sh', '$1' } - into "${rootDir}/.git/hooks" + into gitHooksDir } task installGitHooks(type: Exec) { @@ -17,7 +19,7 @@ task installGitHooks(type: Exec) { group 'git hooks' workingDir rootDir commandLine 'chmod' - args '-R', '+x', '.git/hooks/' + args '-R', '+x', gitHooksDir onlyIf { isLinuxOrMacOs() } dependsOn copyGitHooks doLast {