diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-03-03 10:03:56 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-03-03 11:39:31 +0100 |
commit | db590c36fea80d51b0751b9d3929b469813b0df1 (patch) | |
tree | f5340a75e71e7fb208856e51175ebac03516ab4f | |
parent | d0fbd3d4da6a0962925f351ea633badb1a78eac7 (diff) | |
download | justbuild-db590c36fea80d51b0751b9d3929b469813b0df1.tar.gz |
just-lock: follow indirection when checking for computed roots
When deciding if a repository is a computed root (i.e., of type
"computed" or "tree structure"), first follow indirections.
Otherwise we would try to read of the "type" entry of a string
which, of course, crashes.
Based on the similar fix for just-import-git.
-rwxr-xr-x | bin/just-lock.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/just-lock.py b/bin/just-lock.py index e220e338..cc0cff03 100755 --- a/bin/just-lock.py +++ b/bin/just-lock.py @@ -782,8 +782,10 @@ def get_repo_to_import(config: Json) -> str: fail("Config does not contain any repositories; unsure what to import") -def get_base_repo_if_computed(repo: Json) -> Optional[str]: +def get_base_repo_if_computed(repo: Any, repos_config: Json) -> Optional[str]: """If repository is computed, return the base repository name.""" + while isinstance(repo, str): + repo = repos_config[repo]["repository"] if repo.get("type") in ["computed", "tree structure"]: return cast(str, repo.get("repo")) return None @@ -820,7 +822,7 @@ def repos_to_import(repos_config: Json, entry: str, visit(repo) else: # if computed, visit the referred repository - repo_base = get_base_repo_if_computed(cast(Json, repo)) + repo_base = get_base_repo_if_computed(repo, repos_config) if repo_base is not None: extra_imports.discard(repo_base) visit(repo_base) @@ -833,8 +835,8 @@ def repos_to_import(repos_config: Json, entry: str, if extra not in known and extra not in to_import: extra_imports.add(extra) extra_repo_base = get_base_repo_if_computed( - cast(Json, - repos_config.get(extra, {}).get("repository", {}))) + repos_config.get(extra, {}).get("repository", {}), + repos_config) if extra_repo_base is not None: extra_imports.discard(extra_repo_base) visit(extra_repo_base) |