diff options
author | Klaus T. Aehlig <aehlig@linta.de> | 2025-03-01 13:14:29 +0100 |
---|---|---|
committer | Klaus T. Aehlig <aehlig@linta.de> | 2025-03-03 10:25:58 +0100 |
commit | d0fbd3d4da6a0962925f351ea633badb1a78eac7 (patch) | |
tree | abd4bdf2a5f0295ef43e44d470cefd71c505ae38 /bin/just-import-git.py | |
parent | 85905abb128c7684ad2760c18c47133d4b146154 (diff) | |
download | justbuild-d0fbd3d4da6a0962925f351ea633badb1a78eac7.tar.gz |
just-import-git: 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.
Diffstat (limited to 'bin/just-import-git.py')
-rwxr-xr-x | bin/just-import-git.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/just-import-git.py b/bin/just-import-git.py index b75deb5c..41be8e17 100755 --- a/bin/just-import-git.py +++ b/bin/just-import-git.py @@ -166,8 +166,10 @@ def get_repo_to_import(config: Json) -> str: fail("Config does not contain any repositories; unsure what to import") -def get_target_if_computed_repo(repo: Json) -> Optional[str]: +def get_target_if_computed_repo(repo: Any, repos_config: Json) -> Optional[str]: """If repository is computed, return the target 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 @@ -204,7 +206,7 @@ def repos_to_import(repos_config: Json, entry: str, visit(repo) else: # if computed, visit the referred repository - target = get_target_if_computed_repo(cast(Json, repo)) + target = get_target_if_computed_repo(repo, repos_config) if target is not None: extra_imports.discard(target) visit(target) @@ -217,8 +219,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_target = get_target_if_computed_repo( - cast(Json, - repos_config.get(extra, {}).get("repository", {}))) + repos_config.get(extra, {}).get("repository", {}), + repos_config) if extra_target is not None: extra_imports.discard(extra_target) visit(extra_target) |