Skip to content

Commit fc9280d

Browse files
committed
fix: convert relative symlinks in test_module_repo to absolute
Although relative links are valid in Windows, it seems that they fail under some circumstances. For example, see bazelbuild/bazel-central-registry#5205
1 parent 337638d commit fc9280d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

buildkite/bazel-central-registry/bcr_presubmit.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,19 @@ def unpack_archive(archive_file, output_dir):
240240
else:
241241
shutil.unpack_archive(archive_file, output_dir)
242242

243+
# Windows has issues with relative symlinks (see
244+
# https://github.com/bazelbuild/bazel-central-registry/pull/5205) so let's
245+
# make all of the symlinks in the unpacked archive absolute
246+
for root, dirs, files in os.walk(output_dir):
247+
for name in files + dirs:
248+
path = pathlib.Path(root) / name
249+
if path.is_symlink():
250+
target = path.readlink()
251+
if not target.is_absolute():
252+
absolute_target = (path.parent / target).resolve()
253+
path.unlink()
254+
path.symlink_to(absolute_target)
255+
243256
def prepare_test_module_repo(module_name, module_version, overwrite_bazel_version=None, root=None, suppress_log=False):
244257
"""Prepare the test module repo and the presubmit yml file it should use"""
245258
suppress_log or bazelci.print_collapsed_group(":information_source: Prepare test module repo")

0 commit comments

Comments
 (0)