fix: copy_to_directory repairs read-only file permissions (#134)
When two srcs have the same nested folder, we need to correct the permissions like bazel's sandbox would. Fixes #133
This commit is contained in:
parent
73bfc53660
commit
695a8c4ad4
|
@ -145,6 +145,12 @@ if [[ -f "{src}" ]]; then
|
|||
mkdir -p "{dst_dir}"
|
||||
cp -f "{src}" "{dst}"
|
||||
else
|
||||
if [[ -d "{dst}" ]]; then
|
||||
# When running outside the sandbox, then an earlier copy will create the dst folder
|
||||
# with nested read-only folders, so our copy operation will fail to write there.
|
||||
# Make sure the output folders are writeable.
|
||||
find "{dst}" -type d -print0 | xargs -0 chmod a+w
|
||||
fi
|
||||
mkdir -p "{dst}"
|
||||
cp -fR "{src}/." "{dst}"
|
||||
fi
|
||||
|
|
|
@ -250,3 +250,29 @@ diff_test(
|
|||
file1 = "case_10",
|
||||
file2 = ":expected_10",
|
||||
)
|
||||
|
||||
copy_directory(
|
||||
name = "g1_out",
|
||||
src = "g1",
|
||||
out = "g1_out",
|
||||
)
|
||||
|
||||
copy_directory(
|
||||
name = "g2_out",
|
||||
src = "g2",
|
||||
out = "g2_out",
|
||||
)
|
||||
|
||||
# Case 11: two inputs with same subfolders
|
||||
# regression test for https://github.com/aspect-build/bazel-lib/issues/133
|
||||
copy_to_directory(
|
||||
name = "case_11",
|
||||
srcs = [
|
||||
"g1_out",
|
||||
"g2_out",
|
||||
],
|
||||
root_paths = [
|
||||
"{}/g1_out".format(package_name()),
|
||||
"{}/g2_out".format(package_name()),
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue