From b61e6ac8e042f9bcc684c10f085553455b13fab1 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 24 Apr 2024 17:08:02 +0200 Subject: just-import-git: support importing repositories as absent This allows to simply specify the direct dependencies desired to be absent at import where the dependency structure is handled anyway, rather than afterwards reconstructing which repositories should be absent. --- bin/just-import-git.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bin/just-import-git.py') diff --git a/bin/just-import-git.py b/bin/just-import-git.py index c362469a..7416bb7b 100755 --- a/bin/just-import-git.py +++ b/bin/just-import-git.py @@ -227,7 +227,7 @@ def name_imports(to_import: List[str], def rewrite_repo(repo_spec: Json, *, remote: Dict[str, Any], - assign: Json) -> Json: + assign: Json, absent: bool) -> Json: new_spec: Json = {} repo = repo_spec.get("repository", {}) if isinstance(repo, str): @@ -242,6 +242,8 @@ def rewrite_repo(repo_spec: Json, *, remote: Dict[str, Any], existing_repos: List[str] = repo.get("repositories", []) new_repos = [assign[k] for k in existing_repos] repo = dict(repo, **{"repositories": new_repos}) + 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: @@ -319,6 +321,7 @@ def handle_import(args: Namespace) -> Json: foreign_repos[repo], remote=remote, assign=total_assign, + absent=args.absent, ) base_config["repositories"] = base_repos shutil.rmtree(to_cleanup) @@ -351,6 +354,11 @@ def main(): help="Pretend the remote repository description is the canonical" + " single-repository one", ) + parser.add_argument( + "--absent", + action="store_true", + help="Import repository and all its dependencies as absent." + ) parser.add_argument( "--as", dest="import_as", -- cgit v1.2.3