Created
December 18, 2025 05:44
-
-
Save alexanderdombroski/7c519f20d95fcec691993d3aab70e295 to your computer and use it in GitHub Desktop.
rust pre-commit formatter for macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Create list of rust files | |
| FILES=() | |
| while IFS= read -r -d '' file; do | |
| FILES+=("$file") | |
| done < <(git diff --cached --name-only -z -- '*.rs') | |
| if [ "${#FILES[@]}" -eq 0 ]; then | |
| exit 0 | |
| fi | |
| cargo fmt -- "${FILES[@]}" | |
| git add -- "${FILES[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment