change pre-commit hook to only check for formatting errors
This commit is contained in:
parent
c26710e13b
commit
30028e4179
1 changed files with 10 additions and 5 deletions
|
@ -1,9 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
log () {
|
||||||
|
printf "[\033[1;37mpre-commit\033[0m] $1\n"
|
||||||
|
}
|
||||||
|
|
||||||
rustfmt +nightly --version &>/dev/null
|
rustfmt +nightly --version &>/dev/null
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
printf "[pre-commit] \033[0;31mERROR\033[0m: rustfmt +nightly not available, install rustfmt via -\n"
|
log "\033[0;33mWARN\033[0m: rustfmt +nightly not found, skipping pre-commit hook"
|
||||||
printf "[pre-commit] \033[0;31mERROR\033[0m: $ rustup component add rustfmt --toolchain nightly\n"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -19,11 +22,13 @@ for file in $(git diff --name-only --cached); do
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$files" ]; then
|
if [ -n "$files" ]; then
|
||||||
|
log "the following files have improper formatting:\n"
|
||||||
for file in "${files[@]}"; do
|
for file in "${files[@]}"; do
|
||||||
rustfmt +nightly $file
|
printf "\033[0;33m\t$file\n"
|
||||||
git add $file
|
|
||||||
printf "[\033[1;32mrustfmt\033[0m] $file\n"
|
|
||||||
done
|
done
|
||||||
|
printf "\n\033[0m"
|
||||||
|
log "aborting commit"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue