This commit adds support for interpreting a new syntax:
jw.include-map:
- /etc/some/file.conf: ../../../file.conf
- /opt/blah/another/config.yaml: ../../../config.yaml
Production configs include absolute paths outside the repository tree, so a
test that runs a production-style document against repository-local copies
must redirect those includes, ideally without modifying the
files meant to be installed as is.
Add a jw.include-map key to the top-level document: an ordered list
of single-key mappings from LHS pattern to RHS pattern or list of RHS
patterns. Before resolution, the file part of each include spec is
qualified against the including file's directory and matched against the
LHS patterns in table order; the first match rewrites the spec to every RHS
pattern of that entry. Relative LHS and RHS values are interpreted against
the directory of the document that declares the map, so matching runs on
canonical paths and same-named includes from different directories stay
distinguishable. The optional marker and the target path are decomposed
before the rewrite: every rewritten source inherits the spec's optionality,
and the target path applies to the merged result.
- _parse_include_map(): parse and validate the table; only '*' is supported
in an LHS, a RHS may not have more '*' than its LHS, and RHS values
expand $(VAR) and ${VAR} from the environment
- _canonicalize_path(): join a relative path with a base directory and
normalize, without disk access
- _compile_lhs_pattern(): compile a canonical LHS into an anchored regex
whose '*' groups match runs that are not '/'
- _apply_include_map(): match the first entry and fill the LHS captures
into every RHS pattern; log the rewrite at DEBUG
- _load_yaml(): parse the map once in the top-level document, reject it in
included documents, thread it through the include tree
Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.6.0