"""Check packaged Git snapshot preparation; no graph, detector or hook-latency claim.""" from __future__ import annotations import json import os import subprocess import tempfile import time from pathlib import Path from openultrasast.model.contracts import ExecutionBudget from openultrasast.push.snapshot import SnapshotAdapter def main() -> None: assert os.getuid() != 0, "exercise the shipped non-root runtime" with tempfile.TemporaryDirectory(prefix="ousast-push-smoke-") as temporary: repo = Path(temporary) / "repository" repo.mkdir() def git(*args: str) -> bytes: return subprocess.run(["git", "-C", str(repo), *args], check=True, capture_output=True, timeout=10).stdout def commit(message: str) -> str: git("add", ".") git("commit", "-m", message) return git("rev-parse", "HEAD").decode().strip() git("init") git("config", "user.name", "Snapshot smoke") git("config", "user.email", "snapshot@example.invalid") git("config", "core.hooksPath", os.devnull) before = ( b"function before(req, res) {\n if (!authorized(req)) return;\n" b" const input = req.body;\n const value = input.value;\n res.send(value);\n}\n" ) after = before.replace(b"function before", b"function after").replace(b" if (!authorized(req)) return;\n", b"") php = b"