Last active
June 18, 2021 15:29
-
-
Save anvie/5a25c448b07774b5d78694e4652ba06f to your computer and use it in GitHub Desktop.
Git pre-commit script to run code formatter automatically
This file contains 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/env bash | |
set -e | |
files=$((git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.rs$") || true) | |
if [ ! -z "${files}" ]; then | |
comma_files=$(echo "$files" | paste -s -d "," -) | |
make fmt | |
git add $(echo "$files" | paste -s -d " " -) | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment