aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
diff options
context:
space:
mode:
authorThomas <>2023-04-11 17:48:32 +0200
committerThomas <>2023-04-11 17:48:32 +0200
commit794640bdb5c144db97faa9cadf1051ff837b7112 (patch)
treedadba255e33ade52f76292ef9a4f13654c0287c8 /build.gradle
parentecee7fc68fa6e729951f3c93f4e9e5a6e1760a38 (diff)
downloadpdf-as-4-794640bdb5c144db97faa9cadf1051ff837b7112.tar.gz
pdf-as-4-794640bdb5c144db97faa9cadf1051ff837b7112.tar.bz2
pdf-as-4-794640bdb5c144db97faa9cadf1051ff837b7112.zip
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.
Diffstat (limited to 'build.gradle')
-rw-r--r--build.gradle18
1 files 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) {