Skip to content

Commit 8846225

Browse files
committed
Default to 0.0.0 if no Git HEAD is present
1 parent 3b034cc commit 8846225

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def getVersionName = { ->
3535
}
3636
return stdout.toString().trim().substring(1)
3737
} catch (org.gradle.process.internal.ExecException e) {
38+
if (!new File(rootDir, '.git/HEAD').exists()) {
39+
println("WARN: Could not fetch Git Tag for build version. No Git HEAD available. Substituting version 0.0.0")
40+
return "0.0.0"
41+
}
3842
println("WARN: Could not fetch Git Tag for build version. Please install Git and add it to your PATH. For now, the Git commit hash has been substituted.")
3943
return getGitCommit()
4044
}
@@ -50,6 +54,10 @@ def getVersionSimple = { ->
5054
}
5155
return stdout.toString().trim().substring(1)
5256
} catch (org.gradle.process.internal.ExecException e) {
57+
if (!new File(rootDir, '.git/HEAD').exists()) {
58+
println("WARN: Could not fetch Git Tag for build version. No Git HEAD available. Substituting version 0.0.0")
59+
return "0.0.0"
60+
}
5361
println("WARN: Could not fetch Git Tag for build version. Please install Git and add it to your PATH. For now, the Git commit hash has been substituted.")
5462
return getGitCommit()
5563
}

0 commit comments

Comments
 (0)