| 353 | cross_hits = {f for f in files if is_cross_cutting(f)} |
| 354 | if ROOT_MANIFEST in files: |
| 355 | if root_manifest_change_is_workspace_members_only(base, head): |
| 356 | print("[detect] root Cargo.toml change is limited to workspace members.") |
| 357 | else: |
| 358 | cross_hits.add(ROOT_MANIFEST) |
| 359 | |
| 360 | if cross_hits: |
| 361 | hit = sorted(cross_hits)[:5] |
| 362 | print(f"[detect] cross-cutting change(s): {hit} -> full workspace.") |
| 363 | return emit("all", [], [], True) |
| 364 | dir2name, deps = workspace_graph() |
| 365 | seeds = {c for c in (owning_crate(f, dir2name) for f in files) if c} |
| 366 | if "Cargo.lock" in files: |
| 367 | if seeds: |
| 368 | print(f"[detect] Cargo.lock change scoped to first-party crates: {sorted(seeds)}") |
| 369 | else: |
| 370 | lock_seeds = lock_affected_members(base, head, set(dir2name.values())) |
| 371 | if lock_seeds is None: |
| 372 | print("[detect] Cargo.lock change not attributable -> full workspace.") |
| 373 | return emit("all", [], [], True) |
| 374 | print(f"[detect] Cargo.lock changes map to crates: {sorted(lock_seeds)}") |
| 375 | seeds |= lock_seeds |
| 376 | if not seeds: |
| 377 | print("[detect] no first-party crate affected (docs/vendored only).") |
| 378 | return emit("none", [], [], False) |
| 379 | test_crates = dependents_closure(seeds, deps) |
| 380 | heavy = sorted(test_crates & vendored_heavy_crates(dir2name, deps)) |
| 381 | if heavy: |
| 382 | print(f"[detect] vendored-heavy test crates: {heavy} -> free disk first.") |
| 383 | return emit("subset", test_crates, seeds, bool(heavy)) |
| 384 | |
| 385 | |
| 386 | def sh(cmd): |
| 387 | print("+", " ".join(cmd)) |