From 794640bdb5c144db97faa9cadf1051ff837b7112 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 11 Apr 2023 17:48:32 +0200 Subject: build(core): Fix the build in the context of a git submodule from TUG: The gradle build file tries to infer the commit hash by reading the files in the .git subdirectory. But in case the repo is checked out as a submodule there is no such directory, only a file pointing to the parent checkout. Instead of depending on git internals just ask git directly. --- build.gradle | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index fe9c877a..ef7fc0a6 100644 --- a/build.gradle +++ b/build.gradle @@ -187,21 +187,9 @@ task releases(type: Copy) { def getCheckedOutGitCommitHash() { - def gitFolder = "$projectDir/.git/" - def takeFromHash = 40 - /* - * '.git/HEAD' contains either - * in case of detached head: the currently checked out commit hash - * otherwise: a reference to a file containing the current commit hash - */ - def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD - def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd - // def isRef = head.length > 1 // ref: refs/heads/master - - if(isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb - - def refHead = new File(gitFolder + head[1].trim()) // .git/refs/heads/master - refHead.text.trim().take takeFromHash + def takeFromHash = 40 + 'git rev-parse --verify HEAD'.execute().text.trim().take takeFromHash + } /* task docs(type: Javadoc) { -- cgit v1.2.3