fractal/hooks/pre-commit.hook
2018-12-13 10:14:59 +00:00

25 lines
610 B
Bash
Executable file

#!/bin/sh
if ! which rustup &> /dev/null; then
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH=$PATH:$HOME/.cargo/bin
if ! which rustup &> /dev/null; then
echo "Failed to install rustup"
fi
fi
if ! rustup component list|grep rustfmt &> /dev/null; then
echo "Installing rustfmt.."
rustup component add rustfmt
fi
echo "--Checking style--"
cargo fmt --all -- --check
if test $? != 0; then
echo "--Checking style fail--"
echo "Please fix the above issues, either manually or by running: cargo fmt --all"
exit -1
else
echo "--Checking style pass--"
fi