homesync/.githooks/pre-commit

14 lines
230 B
Bash
Executable File

#!/bin/bash
set -e
filesToFormat=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.rs/ {print $NF}'
)
for path in $filesToFormat
do
rustfmt --edition 2021 $path
git add $path
done;