mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-01-02 01:20:10 +01:00
pre-commit doesn't modify files, just checks foramtting
This commit is contained in:
@@ -51,23 +51,6 @@ else
|
||||
printf "${SUCCESS}\n"
|
||||
fi
|
||||
|
||||
function fmt() {
|
||||
printf "${PREFIX} Running rustfmt on $1 ... "
|
||||
(cd $1 && cargo-fmt -q)
|
||||
FMTRESULT=$?
|
||||
if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then
|
||||
printf "${SKIPPED}\n"
|
||||
elif [ ${FMTRESULT} != 0 ]; then
|
||||
FAILED=1
|
||||
printf "${FAILURE}\n"
|
||||
else
|
||||
printf "${SUCCESS}\n"
|
||||
fi
|
||||
}
|
||||
|
||||
fmt tarpc
|
||||
fmt tarpc_examples
|
||||
|
||||
printf "${PREFIX} Checking for bad whitespace ... "
|
||||
git diff-index --check --cached $against -- &>/dev/null
|
||||
if [ "$?" != 0 ]; then
|
||||
@@ -77,6 +60,28 @@ else
|
||||
printf "${SUCCESS}\n"
|
||||
fi
|
||||
|
||||
printf "${PREFIX} Checking formatting ... "
|
||||
FMTRESULT=0
|
||||
for file in $(git diff --name-only --cached);
|
||||
do
|
||||
if [ ${file: -3} == ".rs" ]; then
|
||||
HASH=$(shasum $file)
|
||||
NEW_HASH=$(rustfmt --write-mode=display $file | shasum)
|
||||
if [ "${HASH}" != "${NEW_HASH}" ]; then
|
||||
FMTRESULT=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then
|
||||
printf "${SKIPPED}\n"$?
|
||||
elif [ ${FMTRESULT} != 0 ]; then
|
||||
FAILED=1
|
||||
printf "${FAILURE}\n"
|
||||
else
|
||||
printf "${SUCCESS}\n"
|
||||
fi
|
||||
|
||||
if [ ${FAILED} != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user