Commit ec2fd4e
authored
chore: add pre-commit config for local Rust lint checks (#1871)
# What does this PR do?
Adds a `.pre-commit-config.yaml` that mirrors CI lint checks for local
development:
- **pre-commit**: `cargo +nightly-2026-02-08 fmt --all` and
`dd-rust-license-tool check` (only on Cargo.toml/lock and license input
changes)
- **pre-push**: `cargo clippy --workspace --all-targets --all-features
-- -D warnings`
# Motivation
Since I started using coding agents, I find pre-commit hooks invaluable
— they greatly reduce back-and-forths and CI costs. The more checks that
run locally before code leaves my machine, the fewer wasted CI cycles
and review round-trips.
I'm not specifically promoting [pre-commit](https://pre-commit.com/)
(the Python tool), but it's a nice framework that's trivial to install,
especially with `uv`:
```bash
uv tool install pre-commit
```
There are probably a million similar frameworks, but this is a nice
example.
# Additional Notes
Completely opt-in. If you haven't configured the git hooks locally, none
of these checks will fire. Install with:
```bash
GIT_CONFIG_GLOBAL=/dev/null pre-commit install
GIT_CONFIG_GLOBAL=/dev/null pre-commit install --hook-type pre-push
```
(`GIT_CONFIG_GLOBAL=/dev/null` works around the DD global
`core.hooksPath` setting.)
rustfmt is pinned to `nightly-2026-02-08` to match CI. Common Components
will follow up with a `rust-toolchain.toml` to make this easier to keep
in sync.
# How to test the change?
1. Install hooks as above
2. Modify a `.rs` file and commit — `cargo fmt` runs automatically
3. Push — `cargo clippy` runs before the push goes through
4. Modify a `Cargo.toml` and commit — `dd-rust-license-tool check` runs1 parent 0a3304c commit ec2fd4e
3 files changed
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
| |||
0 commit comments