PyTorch fixes linter reliability in partial git clones with PR #191364
A redesign separates offline and network git commands to prevent linter failures.
The PyTorch team tackled a recurring issue where linters in CI would fail due to partial git clones. Previous attempts, like PR #191228, enforced strict local-only git commands, but this caused errors when accessing historical file versions. The new approach, implemented in PR #191364 by janeyx99 and Codex, separates git commands into two categories: those that must remain offline and those that may contact the network.
Offline commands include merge-base with origin/main, working-tree diff, and initial attempts at historical object commands. These rely on the local checkout's full commit history. Network-dependent commands (latter attempts at historical file content) use `git diff`, `git ls-tree`, and `git cat-file` after a local failure. The fix also removes `git ls-remote`, explicit `git fetch origin <oid>`, and automatic ref updates, preventing conflicts from concurrent lint runs. This design ensures stable linter execution even with treeless checkouts and fetch-depth:0.
- Separates git commands into offline (merge-base, working-tree diff) and network-dependent (historical file content) categories.
- Removes explicit `git fetch origin` and `git ls-remote` to avoid GitHub rejection of blob requests.
- Relies on local checkout with full commit history for offline operations, improving CI reliability.
Why It Matters
Stable linters in partial clones reduce CI failures, saving developer time and improving PyTorch's development workflow.