From f5f390089d25573e27ffb0f8d4dce37bb731c1ee Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 17 Jun 2025 15:37:15 +0200 Subject: Add auto-formatting of json file Given the just added json-file formatter, we can generate a diff formatting properly all json files, i.e., all target, rules, and expression files, by applying that formatter to every target file and combining the patches. A target description doing precisely this can easily be obtained as computed root. In this way, we also make good use of caching. To avoid doing recomputing the target description unnecessarily, we factor through the tree structure of the repository tree; the latter, we obtain from the to-git view of the top-level directory, whereas for computing the diff we use the actual (not necessarily committed) files. --- etc/repos.in.json | 26 ++++++++++++++++++++++++ etc/repos.json | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) (limited to 'etc') diff --git a/etc/repos.in.json b/etc/repos.in.json index aab0a492..6b98b384 100644 --- a/etc/repos.in.json +++ b/etc/repos.in.json @@ -497,6 +497,32 @@ , "lzma": "lzma" } } + , "repo": + {"repository": {"type": "file", "path": ".", "pragma": {"to_git": true}}} + , "format-json infra": + { "repository": + {"type": "file", "path": "format-json", "pragma": {"to_git": true}} + } + , "repo tree": + { "repository": {"type": "tree structure", "repo": "repo"} + , "target_file_name": "TARGETS.tasks" + , "target_root": "format-json infra" + , "bindings": {"format": "format-json infra"} + } + , "format-json/tasks": + { "repository": + {"type": "computed", "repo": "repo tree", "target": ["", ""]} + } + , "format-json/bin": + { "repository": {"type": "file", "path": "bin", "pragma": {"to_git": true}} + , "target_root": "format-json infra" + } + , "format-json": + { "repository": {"type": "file", "path": "."} + , "target_root": "format-json/tasks" + , "rule_root": "format-json infra" + , "bindings": {"bin": "format-json/bin"} + } } , "imports": [ { "source": "git" diff --git a/etc/repos.json b/etc/repos.json index d444c262..fdc5e57f 100644 --- a/etc/repos.json +++ b/etc/repos.json @@ -657,6 +657,66 @@ "lzma": "lzma" } }, + "repo": { + "repository": { + "type": "file", + "path": ".", + "pragma": { + "to_git": true + } + } + }, + "format-json infra": { + "repository": { + "type": "file", + "path": "format-json", + "pragma": { + "to_git": true + } + } + }, + "repo tree": { + "repository": { + "type": "tree structure", + "repo": "repo" + }, + "target_file_name": "TARGETS.tasks", + "target_root": "format-json infra", + "bindings": { + "format": "format-json infra" + } + }, + "format-json/tasks": { + "repository": { + "type": "computed", + "repo": "repo tree", + "target": [ + "", + "" + ] + } + }, + "format-json/bin": { + "repository": { + "type": "file", + "path": "bin", + "pragma": { + "to_git": true + } + }, + "target_root": "format-json infra" + }, + "format-json": { + "repository": { + "type": "file", + "path": "." + }, + "target_root": "format-json/tasks", + "rule_root": "format-json infra", + "bindings": { + "bin": "format-json/bin" + } + }, "clang-18": { "repository": "clang-18/toolchains", "target_file_name": "clang.TARGETS", -- cgit v1.2.3