From a3f2317ac88fddc15e6b09d1f9e362a530ea1b6b Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 16 Jan 2020 10:10:31 -0800 Subject: [PATCH] Fix git info within VM for worktrees If a worktree is used, say for 7.x, and packaging tests are run, the build within the VM will fail due to the parent checkout not being accessible. This is because the path of the worktree is for the host systtem, not the VM. This commit makes the git info unknown, just as if the .git directory did not exist. --- .../org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java index dbe13916a2858..e014d2e04108d 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java @@ -263,6 +263,9 @@ public static String gitRevision(File rootDir) { } else { // this is a git worktree, follow the pointer to the repository final Path workTree = Paths.get(readFirstLine(dotGit).substring("gitdir:".length()).trim()); + if (Files.exists(workTree) == false) { + return "unknown"; + } head = workTree.resolve("HEAD"); final Path commonDir = Paths.get(readFirstLine(workTree.resolve("commondir"))); if (commonDir.isAbsolute()) {