From f5a09af3a3196b8a3d250a664efd03b399d70da7 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 27 Jan 2025 10:17:18 +0100 Subject: just-lock config: Make field names consistent with just-mr --- bin/just-lock.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'bin/just-lock.py') diff --git a/bin/just-lock.py b/bin/just-lock.py index e8c6b2d7..b4cdd078 100755 --- a/bin/just-lock.py +++ b/bin/just-lock.py @@ -666,7 +666,7 @@ def rewrite_file_repo(repo: Json, remote_type: str, remote_stub: Dict[str, Any], subdir = os.path.join(existing, subdir) changes["subdir"] = subdir return dict(remote_stub, **changes) - elif remote_type == "git-tree": + elif remote_type == "git tree": # for imports from git-trees, file repos become 'git tree' types; the # subtree Git identifier is computed relative to the root Git tree, so # compute and validate the subtree path based on the source tree subdir @@ -963,16 +963,16 @@ def import_from_git(core_repos: Json, imports_entry: Json) -> Json: "Expected field \"mirrors\" to be a list, but found:\n%r" % (json.dumps(mirrors, indent=2), )) - inherit_env: Optional[List[str]] = imports_entry.get("inherit_env", []) + inherit_env: Optional[List[str]] = imports_entry.get("inherit env", []) if inherit_env is not None and not isinstance(inherit_env, list): fail(fail_context + - "Expected field \"inherit_env\" to be a list, but found:\n%r" % + "Expected field \"inherit env\" to be a list, but found:\n%r" % (json.dumps(inherit_env, indent=2), )) - as_plain: Optional[bool] = imports_entry.get("as_plain", False) + as_plain: Optional[bool] = imports_entry.get("as plain", False) if as_plain is not None and not isinstance(as_plain, bool): fail(fail_context + - "Expected field \"as_plain\" to be a bool, but found:\n%r" % + "Expected field \"as plain\" to be a bool, but found:\n%r" % (json.dumps(as_plain, indent=2), )) foreign_config_file: Optional[str] = imports_entry.get("config", None) @@ -1062,10 +1062,10 @@ def import_from_file(core_repos: Json, imports_entry: Json) -> Json: "Expected field \"path\" to be a string, but found:\n%r" % (json.dumps(path, indent=2), )) - as_plain: Optional[bool] = imports_entry.get("as_plain", False) + as_plain: Optional[bool] = imports_entry.get("as plain", False) if as_plain is not None and not isinstance(as_plain, bool): fail(fail_context + - "Expected field \"as_plain\" to be a bool, but found:\n%r" % + "Expected field \"as plain\" to be a bool, but found:\n%r" % (json.dumps(as_plain, indent=2), )) foreign_config_file: Optional[str] = imports_entry.get("config", None) @@ -1332,10 +1332,10 @@ def import_from_archive(core_repos: Json, imports_entry: Json) -> Json: if subdir == ".": subdir = None # treat as if missing - as_plain: Optional[bool] = imports_entry.get("as_plain", False) + as_plain: Optional[bool] = imports_entry.get("as plain", False) if as_plain is not None and not isinstance(as_plain, bool): fail(fail_context + - "Expected field \"as_plain\" to be a bool, but found:\n%r" % + "Expected field \"as plain\" to be a bool, but found:\n%r" % (json.dumps(as_plain, indent=2), )) foreign_config_file: Optional[str] = imports_entry.get("config", None) @@ -1446,7 +1446,7 @@ def git_tree_checkout(command: List[str], do_generate: bool, *, # Import root tree to Git cache; as we do not have the tree hash, identify # commits by the hash of the generating command instead tree_id = import_to_git(workdir, - repo_type="git-tree", + repo_type="git tree", content_id=git_hash( json.dumps(command).encode('utf-8'))[0], fail_context=fail_context) @@ -1474,7 +1474,7 @@ def import_from_git_tree(core_repos: Json, imports_entry: Json) -> Json: """Handles imports from general Git trees obtained by running a command (explicitly given or generated by a given command).""" # Set granular logging message - fail_context: str = "While importing from source \"git-tree\":\n" + fail_context: str = "While importing from source \"git tree\":\n" # Get the repositories list repos: List[Any] = imports_entry.get("repos", []) @@ -1493,14 +1493,14 @@ def import_from_git_tree(core_repos: Json, imports_entry: Json) -> Json: fail(fail_context + "Expected field \"cmd\" to be a list, but found:\n%r" % (json.dumps(command, indent=2), )) - command_gen: Optional[List[str]] = imports_entry.get("cmd_gen", None) + command_gen: Optional[List[str]] = imports_entry.get("cmd gen", None) if command_gen is not None and not isinstance(command_gen, list): fail(fail_context + - "Expected field \"cmd_gen\" to be a list, but found:\n%r" % + "Expected field \"cmd gen\" to be a list, but found:\n%r" % (json.dumps(command_gen, indent=2), )) if command is None == command_gen is None: fail(fail_context + - "Only one of fields \"cmd\" and \"cmd_gen\" must be provided!") + "Only one of fields \"cmd\" and \"cmd gen\" must be provided!") subdir: Optional[str] = imports_entry.get("subdir", None) if subdir is not None: @@ -1523,16 +1523,16 @@ def import_from_git_tree(core_repos: Json, imports_entry: Json) -> Json: "Expected field \"env\" to be a map, but found:\n%r" % (json.dumps(command_env, indent=2), )) - inherit_env: Optional[List[str]] = imports_entry.get("inherit_env", []) + inherit_env: Optional[List[str]] = imports_entry.get("inherit env", []) if inherit_env is not None and not isinstance(inherit_env, list): fail(fail_context + - "Expected field \"inherit_env\" to be a list, but found:\n%r" % + "Expected field \"inherit env\" to be a list, but found:\n%r" % (json.dumps(inherit_env, indent=2), )) - as_plain: Optional[bool] = imports_entry.get("as_plain", False) + as_plain: Optional[bool] = imports_entry.get("as plain", False) if as_plain is not None and not isinstance(as_plain, bool): fail(fail_context + - "Expected field \"as_plain\" to be a bool, but found:\n%r" % + "Expected field \"as plain\" to be a bool, but found:\n%r" % (json.dumps(as_plain, indent=2), )) foreign_config_file: Optional[str] = imports_entry.get("config", None) @@ -1583,7 +1583,7 @@ def import_from_git_tree(core_repos: Json, imports_entry: Json) -> Json: (json.dumps(repo_entry, indent=2), )) repo_entry = cast(Json, repo_entry) - core_repos = handle_import("git-tree", + core_repos = handle_import("git tree", remote_stub, repo_entry, core_repos, @@ -1923,7 +1923,7 @@ def lock_config(input_file: str) -> Json: elif source == "archive": core_config["repositories"] = import_from_archive( core_config["repositories"], entry) - elif source == "git-tree": + elif source == "git tree": core_config["repositories"] = import_from_git_tree( core_config["repositories"], entry) elif source == "generic": -- cgit v1.2.3