Solving MAXSAT and saying a few words about it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
806 B

#!/bin/bash
# Modification of https://gist.github.com/eugene-babichenko/ca9645fa8b579b9c56668f7b0eb74095
HAS_ISSUES=0
FIRST_FILE=1
for file in $(git diff --name-only --staged); do
if [ "${file: -3}" == ".rs" ]; then
FMT_RESULT="$(rustfmt --unstable-features --skip-children --check $file 2>/dev/null || true)"
MODE_LINE="$(head -n1 $file || true)"
if [ "$FMT_RESULT" != "" -o "$MODE_LINE" != "// vim: ts=4 sw=4 et" ]; then
if [ $FIRST_FILE -eq 0 ]; then
echo -n ", "
fi
echo -n "$file"
HAS_ISSUES=1
FIRST_FILE=0
fi
fi
done
if [ $HAS_ISSUES -eq 0 ]; then
exit 0
fi
echo ". Your code has formatting issues or missing modelines in files listed above. Format your code with rustfmt. (Use rustfmt --check to see what mistakes there are.)"
exit 1