f857e72e26
The hook also checks for rustup and nightly rustfmt and installs them if they are not available.
25 lines
692 B
Bash
Executable file
25 lines
692 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 --toolchain nightly|grep rustfmt-preview &> /dev/null; then
|
|
echo "Installing nightly rustfmt.."
|
|
rustup component add rustfmt-preview --toolchain nightly
|
|
fi
|
|
|
|
echo "--Checking style--"
|
|
cargo +nightly fmt --all -- --check
|
|
if test $? != 0; then
|
|
echo "--Checking style fail--"
|
|
echo "Please fix the above issues, either manually or by running: cargo +nightly fmt --all"
|
|
|
|
exit -1
|
|
else
|
|
echo "--Checking style pass--"
|
|
fi
|