37 lines
1.9 KiB
Python
37 lines
1.9 KiB
Python
"""Integrate the reviewed Warden source revision; no live or trust changes."""
|
|
from datetime import datetime, timezone
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
ROOT = Path(__file__).resolve().parent / "warden-browser"
|
|
OWNER = Path("/home/worsch/ops-warden")
|
|
EXPECTED = "1fb05b513c4db784f8691b5bc2790f5ca396071d4354615d2da7fc505c45684b"
|
|
|
|
|
|
def main():
|
|
manifest = json.loads((ROOT / "manifest.json").read_text())
|
|
patch = ROOT / "implementation.patch"
|
|
assert hashlib.sha256(patch.read_bytes()).hexdigest() == EXPECTED
|
|
head = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=OWNER, text=True).strip()
|
|
assert head == manifest["base_commit"], "owner HEAD changed"
|
|
files = manifest["files"]
|
|
assert not subprocess.check_output(["git", "diff", "HEAD", "--", *files], cwd=OWNER), "target files changed"
|
|
for name in files:
|
|
tracked = subprocess.run(["git", "ls-files", "--error-unmatch", name], cwd=OWNER, capture_output=True).returncode == 0
|
|
assert tracked or not (OWNER / name).exists(), "untracked target collision"
|
|
subprocess.run(["git", "apply", "--check", str(patch)], cwd=OWNER, check=True)
|
|
subprocess.run(["git", "apply", str(patch)], cwd=OWNER, check=True)
|
|
for name, expected in files.items():
|
|
assert hashlib.sha256((OWNER / name).read_bytes()).hexdigest() == expected.removeprefix("sha256:"), name
|
|
receipt = {"repo": "ops-warden", "base_commit": head, "patch_sha256": EXPECTED,
|
|
"integrated_at": datetime.now(timezone.utc).isoformat(), "files_sha256": files,
|
|
"source_integrated": True, "committed": False, "published": False,
|
|
"native_accepted": False, "independent_tests": "102 passed in 12.91s"}
|
|
(ROOT / "canonical-integration.json").write_text(json.dumps(receipt, indent=2) + "\n")
|
|
print("ops-warden: five exact reviewed source files integrated")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|