| 58 | |
| 59 | |
| 60 | def clone_repo(name: str, url: str, skip_clone: bool) -> Path: |
| 61 | dest = CLONE_DIR / name |
| 62 | if dest.exists(): |
| 63 | log(f"{name}: reusing existing clone at {dest}") |
| 64 | return dest |
| 65 | if skip_clone: |
| 66 | raise FileNotFoundError(f"{name}: --skip-clone requested but {dest} does not exist") |
| 67 | CLONE_DIR.mkdir(parents=True, exist_ok=True) |
| 68 | log(f"{name}: cloning {url} (shallow, depth=1) ...") |
| 69 | subprocess.run( |
| 70 | ["git", "clone", "--depth=1", "--single-branch", url, str(dest)], |
| 71 | check=True, |
| 72 | capture_output=True, |
| 73 | text=True, |
| 74 | ) |
| 75 | return dest |
| 76 | |
| 77 | |
| 78 | def naive_source_size(root: str) -> int: |