COMP: Run kw commit-msg hooks via pre-commit-managed Python#6522
Open
hjmjohnson wants to merge 1 commit into
Open
COMP: Run kw commit-msg hooks via pre-commit-managed Python#6522hjmjohnson wants to merge 1 commit into
hjmjohnson wants to merge 1 commit into
Conversation
The kw-commit-msg and kw-prose-budget hooks invoked Utilities/Hooks/run-pixi-python.sh, which hardcoded the CWD-relative path ./.pixi/envs/pre-commit/bin/python. That pixi environment is per-worktree and only exists where `pixi install -e pre-commit` has run, so the hooks failed in fresh git worktrees that built with a different pixi environment. Use pre-commit's own managed Python environment (language: python), matching the other repo hooks whose envs live in the shared pre-commit cache. The scripts are stdlib-only, so no additional dependencies are required. Remove the now-unused launcher.
Contributor
|
| Filename | Overview |
|---|---|
| .pre-commit-config.yaml | Updates the two commit-message hook entries to use pre-commit-managed Python while keeping the same script invocation shape. |
| Utilities/Hooks/run-pixi-python.sh | Removes the pixi-specific launcher after the changed hook entries no longer reference it. |
Reviews (1): Last reviewed commit: "COMP: Run kw commit-msg hooks via pre-co..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
kw-commit-msgandkw-prose-budgethooks ran viaUtilities/Hooks/run-pixi-python.sh, which hardcoded the CWD-relative path./.pixi/envs/pre-commit/bin/python. That pixi environment is per-worktree and only exists wherepixi install -e pre-commithas run, so the hooks fail in freshgit worktrees built with a different pixi environment. This moves the two hooks onto pre-commit's own managed-environment mechanism (language: python) — the same one already used by gersemi/clang-format/black — and removes the launcher.Why this is the right mechanism
~/.cache/pre-commit(keyed to the repo, reused across all worktrees), not in per-worktree.pixi/envs/.kw-commit-msg.pyandkw-prose-budget.pyimport only the standard library (os,re,subprocess,sys,pathlib), so noadditional_dependenciesare needed.run-pixi-python.sh, added 2025-06-26) post-dated pre-commit adoption (2024-12-04); it reached for the pixi env instead of pre-commit's own env management.Local verification
Reproduced the original failure in a fresh worktree, then with the pixi
pre-commitenv deleted confirmed pre-commit builds its own venv and both hooks pass:pre-commit run --all-filesis green (gersemi, clang-format, black, all checks).