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

  1. #!/bin/bash
  2. # Modification of https://gist.github.com/eugene-babichenko/ca9645fa8b579b9c56668f7b0eb74095
  3. HAS_ISSUES=0
  4. FIRST_FILE=1
  5. for file in $(git diff --name-only --staged); do
  6. if [ "${file: -3}" == ".rs" ]; then
  7. FMT_RESULT="$(rustfmt --unstable-features --skip-children --check $file 2>/dev/null || true)"
  8. MODE_LINE="$(head -n1 $file || true)"
  9. if [ "$FMT_RESULT" != "" -o "$MODE_LINE" != "// vim: ts=4 sw=4 et" ]; then
  10. if [ $FIRST_FILE -eq 0 ]; then
  11. echo -n ", "
  12. fi
  13. echo -n "$file"
  14. HAS_ISSUES=1
  15. FIRST_FILE=0
  16. fi
  17. fi
  18. done
  19. if [ $HAS_ISSUES -eq 0 ]; then
  20. exit 0
  21. fi
  22. 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.)"
  23. exit 1