Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(lefthook): scope rust-fmt check to staged files (#4136)

Vitalik699418bf0dfa
diff --git a/lefthook.yml b/lefthook.yml
index a724b6022..c041a5e7e 100644
--- a/lefthook.yml
+++ b/lefthook.yml
@@ -17,7 +17,12 @@ pre-commit:
commands:
rust-fmt:
glob: "*.rs"
- run: cargo fmt --check -- {staged_files}
+ # `cargo fmt -- <files>` ignores the file args and reformats the WHOLE
+ # workspace, so it false-fails on pre-existing drift in files the commit
+ # never touched. Call rustfmt directly to honor "only on STAGED files".
+ # `--` keeps any odd file name (e.g. one starting with '-') from being
+ # parsed as a flag.
+ run: rustfmt --edition 2021 --check -- {staged_files}
rust-clippy:
# Only run clippy on the crates that have at least one staged .rs file.