load_yaml: Fix jw.include overriding local content
When jw.include merges content at a target path, the local content in the main document should take precedence over the included content (siblings win, and the main file is the ultimate source of truth). Fix _merge_at_path so that root's existing content at the target path wins over the value being merged in. Also update the test_include_override_existing test to reflect the correct semantics: local content overrides included content. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
c514ae9077
commit
b18b2f0b65
1 changed files with 6 additions and 4 deletions
|
|
@ -36,7 +36,8 @@ def _merge_at_path(root: dict[str, Any], path: tuple[str, ...],
|
|||
last_key = path[-1]
|
||||
if (last_key in current and isinstance(current[last_key], dict)
|
||||
and isinstance(value, dict)):
|
||||
current[last_key] = _deep_merge(current[last_key], value)
|
||||
# root's existing content wins (merge value into root)
|
||||
current[last_key] = _deep_merge(value, current[last_key])
|
||||
else:
|
||||
current[last_key] = deepcopy(value)
|
||||
return root
|
||||
|
|
|
|||
Loading…
Reference in a new issue