set -e
if git-rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
function grep-check {
test="$1"
ignore="$2"
msg="$3"
if (git diff --cached | egrep -i "$test" | grep -v IGNORE:"$ignore"); then
echo "Error: $msg (This message can be suppressed by adding the string IGNORE:$ignore to the same line.)"
exit 1
fi
}
function grep-check-case-sensitive {
test="$1"
ignore="$2"
msg="$3"
if (git diff --cached | egrep "$test" | grep -v IGNORE:"$ignore"); then
echo "Error: $msg (This message can be suppressed by adding the string IGNORE:$ignore to the same line.)"
exit 1
fi
}
grep-check-case-sensitive \
NOCOMMIT `#IGNORE:NOCOMMIT` \
NOCOMMIT `#IGNORE:NOCOMMIT` \
"Found a line tagged with NOCOMMIT."
cargo fmt --all -- --check
cargo build --all-targets
cargo test --release
exec git diff-index --check --cached $against --