Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- reset='\033[0m'
- bold='\033[1m'
- dim='\033[2m'
- bg_black='\033[40m'
- yellow='\033[33m'
- COUNTER=0
- COUNTER_SORT=0
- COUNTER_FLAKE=0
- FILES=`git diff --cached --name-only --diff-filter=ACM`
- TO_SORT=""
- echo
- echo -e "${dim}######################${reset}"
- echo -e "${bold}CHECKING flake errors${reset}"
- echo -e "${dim}######################${reset}"
- echo
- while read -r fname; do
- if [[ $fname == *.py ]]
- then
- isort -q -c $fname &> /dev/null
- if [ $? -eq 1 ]; then
- TO_SORT+=" $fname"
- ((COUNTER_SORT++))
- fi
- flake8 $fname
- COUNTER_FLAKE=$(expr $COUNTER_FLAKE + $?)
- fi
- done <<< "$FILES"
- if [ "$TO_SORT" != "" ]; then
- echo
- echo -e "${dim}######################${reset}"
- echo -e "${bold}TO FIX IMPORTS RUN:${reset}"
- echo -e "${dim}######################${reset}"
- echo -e -n "${bg_black}${yellow}isort "
- echo -n $TO_SORT
- echo -e -n "${reset}"
- echo
- fi
- exit $(expr $COUNTER_SORT + $COUNTER_FLAKE)
Add Comment
Please, Sign In to add comment