forked from DGNum/gestioCOF
Merge branch 'Kerl/linters' into 'aureplop/linters'
Script de pre-commit plus robuste See merge request cof-geek/gestioCOF!319
This commit is contained in:
commit
fc4b852bde
2 changed files with 15 additions and 16 deletions
|
@ -42,7 +42,7 @@ test:
|
|||
paths:
|
||||
- vendor/
|
||||
# For GitLab CI to get coverage from build.
|
||||
# Keep this disabled for now, at it may kill GitLab...
|
||||
# Keep this disabled for now, as it may kill GitLab...
|
||||
# coverage: '/TOTAL.*\s(\d+\.\d+)\%$/'
|
||||
|
||||
linters:
|
||||
|
|
|
@ -17,18 +17,18 @@ STAGED_PYTHON_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".p
|
|||
printf "> black ... "
|
||||
|
||||
if type black &>/dev/null; then
|
||||
if [ -z $STAGED_PYTHON_FILES ]; then
|
||||
if [ -z "$STAGED_PYTHON_FILES" ]; then
|
||||
printf "OK\n"
|
||||
else
|
||||
BLACK_OUTPUT="/tmp/gc-black-output.log"
|
||||
touch $BLACK_OUTPUT
|
||||
black --check $STAGED_PYTHON_FILES &>$BLACK_OUTPUT
|
||||
printf "OK\n"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
black $STAGED_PYTHON_FILES &>$BLACK_OUTPUT
|
||||
if ! black --check "$STAGED_PYTHON_FILES" &>$BLACK_OUTPUT; then
|
||||
black "$STAGED_PYTHON_FILES" &>$BLACK_OUTPUT
|
||||
tail -1 $BLACK_OUTPUT
|
||||
formatter_updated=1
|
||||
else
|
||||
printf "OK\n"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
@ -41,18 +41,18 @@ fi
|
|||
printf "> isort ... "
|
||||
|
||||
if type isort &>/dev/null; then
|
||||
if [ -z $STAGED_PYTHON_FILES ]; then
|
||||
if [ -z "$STAGED_PYTHON_FILES" ]; then
|
||||
printf "OK\n"
|
||||
else
|
||||
ISORT_OUTPUT="/tmp/gc-isort-output.log"
|
||||
touch $ISORT_OUTPUT
|
||||
isort --check-only $STAGED_PYTHON_FILES &>$ISORT_OUTPUT
|
||||
printf "OK\n"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
isort $STAGED_PYTHON_FILES &>$ISORT_OUTPUT
|
||||
if ! isort --check-only "$STAGED_PYTHON_FILES" &>$ISORT_OUTPUT; then
|
||||
isort "$STAGED_PYTHON_FILES" &>$ISORT_OUTPUT
|
||||
printf "Reformatted.\n"
|
||||
formatter_updated=1
|
||||
else
|
||||
printf "OK\n"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
@ -65,19 +65,18 @@ fi
|
|||
printf "> flake8 ... "
|
||||
|
||||
if type flake8 &>/dev/null; then
|
||||
if [ -z $STAGED_PYTHON_FILES ]; then
|
||||
if [ -z "$STAGED_PYTHON_FILES" ]; then
|
||||
printf "OK\n"
|
||||
else
|
||||
FLAKE8_OUTPUT="/tmp/gc-flake8-output.log"
|
||||
touch $FLAKE8_OUTPUT
|
||||
flake8 $STAGED_PYTHON_FILES &>$FLAKE8_OUTPUT
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
printf "OK\n"
|
||||
else
|
||||
if ! flake8 "$STAGED_PYTHON_FILES" &>$FLAKE8_OUTPUT; then
|
||||
printf "FAIL\n"
|
||||
cat $FLAKE8_OUTPUT
|
||||
checker_dirty=1
|
||||
else
|
||||
printf "OK\n"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue