summaryrefslogtreecommitdiff
path: root/bin/just-import-git.py
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-04-24 17:08:02 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-04-25 16:34:02 +0200
commitb61e6ac8e042f9bcc684c10f085553455b13fab1 (patch)
tree7c65b078fe13964e12ef651a6e5ba8cdb0b66bfc /bin/just-import-git.py
parent61d8ba2b7b60c3181258508954bd83c99aff1397 (diff)
downloadjustbuild-b61e6ac8e042f9bcc684c10f085553455b13fab1.tar.gz
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.
Diffstat (limited to 'bin/just-import-git.py')
-rwxr-xr-xbin/just-import-git.py10
1 files changed, 9 insertions, 1 deletions
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)
@@ -352,6 +355,11 @@ def main():
" 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",
help="Name prefix to import the foreign repository as",