Guest User

Untitled

a guest
Apr 26th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. reset='\033[0m'
  4. bold='\033[1m'
  5. dim='\033[2m'
  6. bg_black='\033[40m'
  7. yellow='\033[33m'
  8.  
  9. COUNTER=0
  10. COUNTER_SORT=0
  11. COUNTER_FLAKE=0
  12.  
  13. FILES=`git diff --cached --name-only --diff-filter=ACM`
  14. TO_SORT=""
  15.  
  16. echo
  17. echo -e "${dim}######################${reset}"
  18. echo -e "${bold}CHECKING flake errors${reset}"
  19. echo -e "${dim}######################${reset}"
  20. echo
  21. while read -r fname; do
  22. if [[ $fname == *.py ]]
  23. then
  24. isort -q -c $fname &> /dev/null
  25. if [ $? -eq 1 ]; then
  26. TO_SORT+=" $fname"
  27. ((COUNTER_SORT++))
  28. fi
  29.  
  30. flake8 $fname
  31. COUNTER_FLAKE=$(expr $COUNTER_FLAKE + $?)
  32. fi
  33. done <<< "$FILES"
  34.  
  35. if [ "$TO_SORT" != "" ]; then
  36. echo
  37. echo -e "${dim}######################${reset}"
  38. echo -e "${bold}TO FIX IMPORTS RUN:${reset}"
  39. echo -e "${dim}######################${reset}"
  40. echo -e -n "${bg_black}${yellow}isort "
  41. echo -n $TO_SORT
  42. echo -e -n "${reset}"
  43. echo
  44. fi
  45.  
  46. exit $(expr $COUNTER_SORT + $COUNTER_FLAKE)
Add Comment
Please, Sign In to add comment