From 44a5e142009932f89f3cd7033a62a85b6ed0c49b Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 28 Feb 2023 13:41:17 +0300 Subject: feat(nix/readTree): implement .skip-tree marker for subtree ignoring With this change, readTree gains the ability to notice a `.skip-tree` marker in addition to the `.skip-subtree` marker. The behaviour of the new marker will completely ignore the folder that the marker is located in (i.e. no node will be present for it in the parent at all). To make this work, the recursive function in readTree had to be modified to return a sentinel value (noting that a tree has requested to be skipped) which is then filtered out when constructing the list of children. The actual `readTree` function is now a wrapper around this inner, sentinel-yielding implementation which unwraps the result set. For obvious reasons, `.skip-tree` is not allowed at the top-level and readTree will throw an error if it encounters it there. Fixes: b/244 Change-Id: Ica731bc1af356e881fd3d31c7109f62ffd2762ea Reviewed-on: https://cl.tvl.fyi/c/depot/+/8185 Autosubmit: tazjin Reviewed-by: flokli Tested-by: BuildkiteCI --- nix/readTree/tests/test-tree-traversal/skip-tree/b/.skip-tree | 1 + nix/readTree/tests/test-tree-traversal/skip-tree/b/default.nix | 1 + 2 files changed, 2 insertions(+) create mode 100644 nix/readTree/tests/test-tree-traversal/skip-tree/b/.skip-tree create mode 100644 nix/readTree/tests/test-tree-traversal/skip-tree/b/default.nix (limited to 'nix/readTree/tests/test-tree-traversal/skip-tree/b') diff --git a/nix/readTree/tests/test-tree-traversal/skip-tree/b/.skip-tree b/nix/readTree/tests/test-tree-traversal/skip-tree/b/.skip-tree new file mode 100644 index 000000000000..34936b45d141 --- /dev/null +++ b/nix/readTree/tests/test-tree-traversal/skip-tree/b/.skip-tree @@ -0,0 +1 @@ +b subfolder should be skipped completely diff --git a/nix/readTree/tests/test-tree-traversal/skip-tree/b/default.nix b/nix/readTree/tests/test-tree-traversal/skip-tree/b/default.nix new file mode 100644 index 000000000000..7903f8e95a38 --- /dev/null +++ b/nix/readTree/tests/test-tree-traversal/skip-tree/b/default.nix @@ -0,0 +1 @@ +throw "b is skipped completely" -- cgit 1.4.1