This is an automated email from the ASF dual-hosted git repository.

mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release24.09 by this push:
     new e613f2d7f0 Fixed: Gradle build failure in a linked git worktree 
(OFBIZ-13470) (#1518)
e613f2d7f0 is described below

commit e613f2d7f055b47766ed3031b3e80f37fad029ef
Author: Mridul Pathak <[email protected]>
AuthorDate: Fri Jul 31 12:23:11 2026 +0530

    Fixed: Gradle build failure in a linked git worktree (OFBIZ-13470) (#1518)
    
    Fixed: Gradle build failure in a linked git worktree (OFBIZ-13470)
    
    `./gradlew` failed in a linked git worktree because the git-hooks plugin
    assumed `$rootDir/.git/hooks` was a directory. In a worktree, `.git` is
    a
    gitlink file instead, so `Files.createDirectories()` threw. Now resolves
    the hooks directory via `git rev-parse --git-common-dir`, which
    correctly
    points to the shared `.git/hooks` in both a normal checkout and a
    worktree.
    
    Backport of #1517.
---
 build.gradle | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/build.gradle b/build.gradle
index de65e5634c..c5ab2b5183 100644
--- a/build.gradle
+++ b/build.gradle
@@ -288,6 +288,10 @@ checkstyle {
     showViolations = true
 }
 gitHooks {
+    // Resolve the real .git dir so this also works from a linked worktree,
+    // where "$rootDir/.git" (the plugin's default) is a gitlink file, not a 
directory.
+    def gitCommonDir = "git -C ${rootDir} rev-parse 
--git-common-dir".execute().text.trim()
+    hooksDirectory.set(new File(rootDir, 
gitCommonDir).toPath().resolve('hooks').toFile())
     hooks = ['pre-push': 'checkstyleMain codenarcMain codenarcTest']
 }
 

Reply via email to