Skip to content

Instantly share code, notes, and snippets.

@mvidner
Created August 29, 2024 09:25
Show Gist options
  • Save mvidner/28168c3d5a3d6aeb4d5654ee93d8f0c9 to your computer and use it in GitHub Desktop.
Save mvidner/28168c3d5a3d6aeb4d5654ee93d8f0c9 to your computer and use it in GitHub Desktop.
.git/hooks/pre-commit to check Rust formatting
#!/bin/sh
# put this to .git/hooks/pre-commit and make it executable
echo PRE-COMMIT HOOK:
set -x
# the repo Rust root is in a subdir
# TODO: skip all of this if there are no changes in that dir
cd rust
# as seen in .github/workflows/ci-rust.yml
cargo fmt --all -- --check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment