generated from eblume/project-template
infra: add cargo-fmt-check pre-push prek hook (mirror CI)
All checks were successful
Build / validate (pull_request) Successful in 5m25s
All checks were successful
Build / validate (pull_request) Successful in 5m25s
The cargo-fmt failure on this PR slipped to CI because the pre-commit prek hooks were never installed in the working clone. The existing cargo-fmt hook reformats in place but only when it runs. Add a pre-push cargo-fmt-check hook (`cargo fmt --all --check`) that mirrors CI's Dagger `check` step exactly, so an unformatted commit is blocked locally before it can reach the runner — even if the pre-commit hook was skipped or not installed. Filtered to .rs pushes so Rust-free pushes pay nothing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8d80208726
commit
7f48a2a1c5
2 changed files with 17 additions and 0 deletions
1
docs/changelog.d/prek-fmt-prepush.infra.md
Normal file
1
docs/changelog.d/prek-fmt-prepush.infra.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Added a `cargo-fmt-check` pre-push prek hook that runs `cargo fmt --all --check` (mirroring CI's Dagger `check` step) whenever a push touches a `.rs` file. The pre-commit `cargo-fmt` hook reformats in place, but only fires when installed and run; the pre-push check is a last-line guard so an unformatted commit can't reach the runner. Run `prek install --hook-type pre-push` to activate it.
|
||||
16
prek.toml
16
prek.toml
|
|
@ -102,6 +102,22 @@ language = "system"
|
|||
files = '\.rs$'
|
||||
pass_filenames = false
|
||||
|
||||
# Pre-push safety net. The pre-commit cargo-fmt hook above reformats in place,
|
||||
# but only when it is installed and actually runs — a commit made before
|
||||
# `prek install`, or via a tool that skips hooks, can still carry unformatted
|
||||
# Rust to CI (where the Dagger `check` step runs `cargo fmt --all --check` and
|
||||
# fails). This hook re-checks at push time, mirroring CI byte-for-byte, so an
|
||||
# unformatted commit is blocked locally before it can reach the runner. It runs
|
||||
# only when the push range touches a .rs file, so Rust-free pushes pay nothing.
|
||||
[[repos.hooks]]
|
||||
id = "cargo-fmt-check"
|
||||
name = "cargo-fmt-check"
|
||||
entry = "cargo fmt --all --check"
|
||||
language = "system"
|
||||
files = '\.rs$'
|
||||
pass_filenames = false
|
||||
stages = ["pre-push"]
|
||||
|
||||
# GitHub/Forgejo Actions workflow linting
|
||||
[[repos]]
|
||||
repo = "https://github.com/rhysd/actionlint"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue