INNER CODE UNIT · Python
init_run
hadriansecurity/OpenHack · src/openhack/run.py:22
def init_run(
target: str,
git_url: str,
run_id: str | None = None,
branch: str | None = None,
) -> Path:
_safe(target, "target")
run_id = run_id or datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
_safe(run_id, "run_id")
path = ensure_run_dirs(target, run_id)
source = path / "sourcecode"
if any(source.iterdir()):
raise FileExistsError(f"sourcecode is not empty: {source}")
cmd = ["git", "clone", "--depth", "1"]
if branch:
cmd += ["--branch", branch]
subprocess.run(cmd + [git_url, str(source)], check=True)
commit = subprocess.check_output(