use pep8 check code by pre-commit git hooks

一点小玩意

$ cat pre-commit
#!/bin/bash

echo '############################'
echo 'pep8 check before git commit'

git status | grep -E 'modified:|new file:|renamed:' | grep '.py$' | awk '{print $NF}' | xargs pep8

if [ $? -ne 0 ];then
    echo -e "\n\e[1;31mexist unclean code, please modify your code to fit require\nor your can use 'git commit --no-verify' to skip this check\e[0m"
    echo '############################'
    exit 1
else
    echo -e "\e[1;32mclean code, nice job!!!\e[0m"
    echo '############################'
    exit 0
fi


你可能感兴趣的:(use pep8 check code by pre-commit git hooks)