Skip to content

Commit 066f733

Browse files
committed
[CI] Simplify root metadata retrieval - add python script
1 parent 68e7a8e commit 066f733

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

tools/filter_unchanged_tangle_roots.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Only keep the ones that changed
3-
filter_unchanged_tangle_roots.py <roots_json> <current> <previous>
3+
filter_unchanged_tangle_roots.py <current> <previous>
44
"""
55

66
import json
@@ -18,13 +18,6 @@
1818
""",
1919
)
2020

21-
parser.add_argument(
22-
"roots_json",
23-
help="""
24-
List of directories to filter, as a json array
25-
""",
26-
)
27-
2821
parser.add_argument(
2922
"current",
3023
help="""
@@ -57,16 +50,16 @@ def hash_dir(dirname):
5750
return h.digest()
5851

5952
def main(args):
60-
sys.stderr.write(f"input: {args.roots_json}\n")
61-
# Dirty fix to transform ["foo", "bar",] into ["foo", "bar"]
62-
clean_roots_json = '[' + args.roots_json.strip('[]').strip().strip(',') + ']'
63-
64-
roots = json.loads(clean_roots_json, strict=False)
53+
with open(join(args.current, "metadata.json"), 'r', encoding='utf-8') as f:
54+
metadata = json.load(f)
55+
roots = metadata["roots"]
56+
sys.stderr.write(f"input: {json.dumps(roots)}\n")
6557

6658
def did_change(root):
6759
current_hash = hash_dir(join(args.current, root))
6860
previous_hash = hash_dir(join(args.previous, root))
6961
return current_hash != previous_hash
62+
7063
changed_roots = list(filter(did_change, roots))
7164

7265
sys.stderr.write(f"output: {changed_roots}\n")

0 commit comments

Comments
 (0)