File size: 798 Bytes
ea3a71e
 
 
 
 
dd90a4c
ea3a71e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd90a4c
 
 
 
ea3a71e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
from __future__ import annotations

import hashlib
from pathlib import Path
import subprocess


ROOT = Path(__file__).resolve().parent
OUT = ROOT / "BUNDLE_SHA256SUMS.txt"


def digest(path: Path) -> str:
    h = hashlib.sha256()
    with path.open("rb") as handle:
        for block in iter(lambda: handle.read(1 << 20), b""):
            h.update(block)
    return h.hexdigest()


rows = []
tracked = subprocess.check_output(["git", "ls-files", "-z"], cwd=ROOT)
for name in sorted(x for x in tracked.decode().split("\0") if x):
    path = ROOT / name
    if path.is_file() and path != OUT:
        rows.append(f"{digest(path)}  {path.relative_to(ROOT).as_posix()}")
OUT.write_text("\n".join(rows) + "\n", encoding="utf-8")
print(f"wrote {len(rows)} entries to {OUT.name}")