Switch to prek rather than pre-commit (#7244)

This provides a native harness with several advantages over
`pre-commit`:

- Faster when initializing the cache
- Smaller cache sizes: under 43mb compared to over 62mb
- Better integration with `uv` for Python usage

Steps for migrating for existing contributors:

1.  Install `prek` following instructions in the updated docs.

2.  Replace hooks in an existing checkout with a special flag:

    ```sh
    prek install --overwrite
    ```

    The `--overwrite` flag is what removes the old hooks.

    If you used the pre-push variant:

    ```sh
    prek install --hook-type pre-push --overwrite
    ```

3.  Optional cleanups:

    ```sh
    rm -rf ~/.cache/pre-commit  # reclaim the old hook-environment cache
pipx uninstall pre-commit # if installed via pipx; or `brew uninstall
pre-commit`
    ```

Assisted-by: Antigravity with Gemini
This commit is contained in:
Chandler Carruth
2026-06-03 19:19:49 +00:00
committed by GitHub
parent 358df53c48
commit 76dd872ab4
12 changed files with 66 additions and 61 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ def _get_cached_binary(name: str, url: str, want_hash: str) -> str:
cache_dir.mkdir(parents=True, exist_ok=True)
# Hold a lock while checksumming and downloading the path. Otherwise,
# parallel runs by pre-commit may conflict with one another with
# parallel runs by prek may conflict with one another with
# simultaneous downloads.
with open(cache_dir.joinpath(f"{name}.lock"), "w") as lock_file:
fcntl.lockf(lock_file.fileno(), fcntl.LOCK_EX)