This repository uses pre-commit with a lightweight configuration that automatically fixes code formatting issues. The pre-commit hooks focus on auto-formatting rather than strict checking, making development smoother while maintaining code consistency.
- Python 3.6+ (for pre-commit)
- Rust toolchain with
rustfmt(for Rust auto-formatting) - Go toolchain with
gofmt(for Go auto-formatting)
-
Install pre-commit:
pip install pre-commit
-
Install the git hook scripts:
pre-commit install
Auto-fixes applied:
- Rust: Automatically formats code using
rustfmt - Go: Automatically formats code using
gofmtand tidies modules withgo mod tidy
Safety checks (non-intrusive):
- Detects merge conflict markers in source files
✅ Automatic fixes - No need to manually run formatting commands
✅ Lightweight - Only essential formatting and basic safety checks
✅ Non-blocking - Focuses on fixes rather than strict linting
✅ Cross-platform - Works on Linux, macOS, and Windows
Once installed, pre-commit will run automatically on every git commit and automatically fix formatting issues. The fixed files will be staged automatically, so you just need to commit again.
Auto-fix all files:
pre-commit run --all-filesRun specific auto-fixes:
pre-commit run rust-fmt-fix # Auto-format Rust code
pre-commit run go-fmt-fix # Auto-format Go code
pre-commit run go-mod-tidy # Clean Go modulesIn rare cases where you need to commit despite hook failures:
git commit --no-verifyWith pre-commit lite, formatting issues are automatically fixed for you:
- Rust: Code is auto-formatted with
rustfmt - Go: Code is auto-formatted with
gofmtand modules are tidied
If the pre-commit hooks make changes, just run git add . and git commit again.
The pre-commit configuration is designed to work seamlessly with the existing GitHub Actions workflows. The same tools used in pre-commit are also used in CI to ensure consistency.
The pre-commit configuration is defined in .pre-commit-config.yaml. This "lite" setup focuses on:
- Auto-formatting rather than strict checking
- Minimal dependencies for easy setup
- Cross-platform compatibility using local hooks
- Essential checks only (merge conflict detection)
The current configuration uses only local hooks to avoid network dependency issues. If you encounter problems, try:
pre-commit clean
pre-commit installEnsure you have the required toolchains installed:
- For Rust:
cargo --version,rustfmt --version - For Go:
go version,gofmt -help
The configuration is tested on Linux, macOS, and Windows (via WSL). On Windows, ensure you're using a POSIX-compatible shell (Git Bash, WSL, or similar).