From 48171d6a20823ea8157b723b223ca0129ac42fde Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 13 Jan 2025 10:47:52 +0100 Subject: import tools: Fix rewrite of unneeded fields The rewrite logic assumes that for repositories taken as layers we will not have certain fields and so they are unconditionally reassigned. Fix this by extending the existing check for bindings to include also alternative roots and root files. --- bin/just-lock.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'bin/just-lock.py') diff --git a/bin/just-lock.py b/bin/just-lock.py index d1895b6e..cc665d5d 100755 --- a/bin/just-lock.py +++ b/bin/just-lock.py @@ -364,14 +364,16 @@ def rewrite_repo(repo_spec: Json, if absent and isinstance(repo, dict): repo["pragma"] = dict(repo.get("pragma", {}), **{"absent": True}) new_spec["repository"] = repo - for key in ["target_root", "rule_root", "expression_root"]: - if key in repo_spec: - new_spec[key] = assign[repo_spec[key]] - for key in ["target_file_name", "rule_file_name", "expression_file_name"]: - if key in repo_spec: - new_spec[key] = repo_spec[key] - # rewrite bindings, if actually needed to be imported + # rewrite other roots and bindings, if actually needed to be imported if not as_layer: + for key in ["target_root", "rule_root", "expression_root"]: + if key in repo_spec: + new_spec[key] = assign[repo_spec[key]] + for key in [ + "target_file_name", "rule_file_name", "expression_file_name" + ]: + if key in repo_spec: + new_spec[key] = repo_spec[key] bindings = repo_spec.get("bindings", {}) new_bindings = {} for k, v in bindings.items(): -- cgit v1.2.3