Skip to content

Commit 87b926a

Browse files
committed
Fix git info within VM for worktrees (#51119)
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.
1 parent 3e3673b commit 87b926a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ public static String gitRevision(File rootDir) {
260260
} else {
261261
// this is a git worktree, follow the pointer to the repository
262262
final Path workTree = Paths.get(readFirstLine(dotGit).substring("gitdir:".length()).trim());
263+
if (Files.exists(workTree) == false) {
264+
return "unknown";
265+
}
263266
head = workTree.resolve("HEAD");
264267
final Path commonDir = Paths.get(readFirstLine(workTree.resolve("commondir")));
265268
if (commonDir.isAbsolute()) {

0 commit comments

Comments
 (0)