mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 13:50:10 +01:00
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:
@@ -171,7 +171,7 @@ def main() -> None:
|
||||
else:
|
||||
git_bin = _find_tool("git")
|
||||
jj_bin = None
|
||||
precommit_bin = _find_tool("pre-commit")
|
||||
prek_bin = _find_tool("prek")
|
||||
|
||||
# Verify there are no uncommitted changes (jj has no equivalent).
|
||||
if git_bin:
|
||||
@@ -263,11 +263,11 @@ def main() -> None:
|
||||
with open(final_path, "w") as final_file:
|
||||
final_file.write(content)
|
||||
|
||||
# Run pre-commit for a ToC update, then push the PR update.
|
||||
# Run prek for a ToC update, then push the PR update.
|
||||
final_desc = "Filling out template with PR %d" % pr_num
|
||||
if git_bin:
|
||||
_run([git_bin, "add", temp_path, final_path])
|
||||
_run([precommit_bin, "run"], check=False)
|
||||
_run([prek_bin, "run"], check=False)
|
||||
_run([git_bin, "commit", "--amend", "-m", final_desc])
|
||||
|
||||
_run([git_bin, "push", "--force-with-lease"])
|
||||
@@ -275,7 +275,7 @@ def main() -> None:
|
||||
assert jj_bin # For mypy.
|
||||
|
||||
_run(
|
||||
[precommit_bin, "run", "--files", "$(jj diff --name-only)"],
|
||||
[prek_bin, "run", "--files", "$(jj diff --name-only)"],
|
||||
check=False,
|
||||
)
|
||||
_run([jj_bin, "describe", "-m", final_desc])
|
||||
|
||||
Reference in New Issue
Block a user