Pre-commit ruff-format hook re-stages reformatted files and blocks commits #37
Labels
No labels
blocked:needs-decision
blocked:preflight
bug
in-progress
in-progress
lint-cleanup
needs-decompose
quickfix
triage-approved
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/pc2cad#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this is
The repo's
.pre-commit-config.yamldefines aruff-formathook thatmodifies staged files in place. When
git commitruns the hook, itreformats the file and re-stages it, which on next commit attempt is
seen as 'unstaged changes detected' by pre-commit, which then re-runs
the hook, which reformats again, which blocks the commit in an
infinite loop. Manual commits with
--no-verifywork but bypasslinting.
Reproduction
Expected
git commitshould commit the staged version after running hooks once.Actual
Pre-commit detects 'unstaged files' (because ruff-format re-staged
them), runs the hook again, which reformats and re-stages, which
triggers the same check. The commit never completes. Manual
git commit --no-verifyworks but bypasses formatting enforcement.Environment
.pre-commit-config.yaml.venv/bin/ruff --versionSuggested fix
Configure
.pre-commit-config.yamlruff-formathook withstages: [manual]orpass_filenames: falseso it does notauto-re-stage, OR add
--no-verifyto the project's standard commitworkflow, OR pin ruff-format to run only on specific paths that
do not conflict with the work being committed.
Why I'm filing this
quickfix-kilo (the Hermes quickfix pipeline) currently uses
--no-verifyas a runner-side workaround for this exact bug. Thatbypasses linting in the commit step. The fix should live in the
repo's pre-commit config, not the runner.
Repro logs: see
/tmp/quickfix-pc2cad-28.logfor the originalfailure trace where
git commitgot stuck in this loop duringthe #28 fix.
Auto-triage: needs decompose
Marked
triage-approved+needs-decompose. decompose-executor will pick this up and break it into implementable sub-issues.