Repository navigation
fix(hooks): rustfmt fallback when cargo fmt exceeds Windows spawn limit - #3658
Merged
Merged
Conversation
This was referenced Nov 15, 2026
Closed
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
Conflict resolution: scripts/git-hooks/pre-commit kept the PR's fail-closed batched check-rustfmt.py gate. Master's staged-file fallback (#3658) is the weaker same-symptom workaround this PR supersedes (whole-workspace coverage vs staged-only, fail-closed vs fail-open); the audit trail on #3569 recommends this direction. Also applies rustfmt --edition 2021 to four master-side files (src/executor/{external_inner,external_redirects,trap_exec}.rs, tests/pipeline_stderr_redirect_streaming.rs) that drifted unformatted under commits that bypassed full-workspace fmt coverage; required so the merged tree passes the gate being introduced. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Problem
scripts/git-hooks/pre-commitrunscargo fmt --check, which enumerates everyworkspace target. With ~700 test targets the spawn command line exceeds the
Windows limit, so cargo dies before formatting anything:
Result: the hook fails on every commit on this machine and everyone is forced
to use
--no-verify, defeating the owner directive that fmt be a commit hook.Fix
Keep
cargo fmt --checkas the primary gate. When it fails:Diff indiagnostics, it is a real formattingfailure — block exactly as before (machines where cargo fmt works keep the
full-repo check).
metadata error). Fall back to running
rustfmt --edition 2021 --checkonthe
.rsfiles staged in this commit only(
git diff --cached --name-only --diff-filter=ACMR | grep '\.rs$').Any unformatted staged file blocks the commit; clean or no staged
.rsfiles passes.
The hook remains a POSIX sh script, runnable under Git Bash.
Verification (this machine, where cargo fmt always hits os error 206)
.rs→ commit blocked (pre-commit: unformatted: <file>)..rs→ commit allowed..rs→ allowed.--no-verify).Generated with Devin