Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#4329] improvement(build): fix get commit id failed as a submodule (#4330)

mchades25b138c6b685
diff --git a/common/build.gradle.kts b/common/build.gradle.kts
index 1f341257cf..91e2d137f2 100644
--- a/common/build.gradle.kts
+++ b/common/build.gradle.kts
@@ -52,13 +52,20 @@ dependencies {
fun getGitCommitId(): String {
var gitCommitId: String
try {
- val gitFolder = rootDir.path + "/.git/"
- val head = File(gitFolder + "HEAD").readText().split(":")
+ val gitPath = File(rootDir.path, ".git")
+ val gitFolder = if (gitPath.isDirectory) {
+ gitPath
+ } else {
+ val content = gitPath.readText().trim()
+ File(rootDir.path, content.substringAfter("gitdir: ").trim())
+ }
+
+ val head = File(gitFolder, "HEAD").readText().split(":")
val isCommit = head.size == 1
gitCommitId = if (isCommit) {
head[0].trim()
} else {
- val refHead = File(gitFolder + head[1].trim())
+ val refHead = File(gitFolder, head[1].trim())
refHead.readText().trim()
}
} catch (e: Exception) {