Skip to content

Commit 1e4ca9e

Browse files
authored
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 89318d4 commit 1e4ca9e

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

+3
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ public static String gitRevision(File rootDir) {
263263
} else {
264264
// this is a git worktree, follow the pointer to the repository
265265
final Path workTree = Paths.get(readFirstLine(dotGit).substring("gitdir:".length()).trim());
266+
if (Files.exists(workTree) == false) {
267+
return "unknown";
268+
}
266269
head = workTree.resolve("HEAD");
267270
final Path commonDir = Paths.get(readFirstLine(workTree.resolve("commondir")));
268271
if (commonDir.isAbsolute()) {

0 commit comments

Comments
 (0)