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:
|
paths:
|
||||||
- vendor/
|
- vendor/
|
||||||
# For GitLab CI to get coverage from build.
|
# 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+)\%$/'
|
# coverage: '/TOTAL.*\s(\d+\.\d+)\%$/'
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
|
|
|
@ -17,18 +17,18 @@ STAGED_PYTHON_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".p
|
||||||
printf "> black ... "
|
printf "> black ... "
|
||||||
|
|
||||||
if type black &>/dev/null; then
|
if type black &>/dev/null; then
|
||||||
if [ -z $STAGED_PYTHON_FILES ]; then
|
if [ -z "$STAGED_PYTHON_FILES" ]; then
|
||||||
printf "OK\n"
|
printf "OK\n"
|
||||||
else
|
else
|
||||||
BLACK_OUTPUT="/tmp/gc-black-output.log"
|
BLACK_OUTPUT="/tmp/gc-black-output.log"
|
||||||
touch $BLACK_OUTPUT
|
touch $BLACK_OUTPUT
|
||||||
black --check $STAGED_PYTHON_FILES &>$BLACK_OUTPUT
|
|
||||||
printf "OK\n"
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if ! black --check "$STAGED_PYTHON_FILES" &>$BLACK_OUTPUT; then
|
||||||
black $STAGED_PYTHON_FILES &>$BLACK_OUTPUT
|
black "$STAGED_PYTHON_FILES" &>$BLACK_OUTPUT
|
||||||
tail -1 $BLACK_OUTPUT
|
tail -1 $BLACK_OUTPUT
|
||||||
formatter_updated=1
|
formatter_updated=1
|
||||||
|
else
|
||||||
|
printf "OK\n"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -41,18 +41,18 @@ fi
|
||||||
printf "> isort ... "
|
printf "> isort ... "
|
||||||
|
|
||||||
if type isort &>/dev/null; then
|
if type isort &>/dev/null; then
|
||||||
if [ -z $STAGED_PYTHON_FILES ]; then
|
if [ -z "$STAGED_PYTHON_FILES" ]; then
|
||||||
printf "OK\n"
|
printf "OK\n"
|
||||||
else
|
else
|
||||||
ISORT_OUTPUT="/tmp/gc-isort-output.log"
|
ISORT_OUTPUT="/tmp/gc-isort-output.log"
|
||||||
touch $ISORT_OUTPUT
|
touch $ISORT_OUTPUT
|
||||||
isort --check-only $STAGED_PYTHON_FILES &>$ISORT_OUTPUT
|
|
||||||
printf "OK\n"
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if ! isort --check-only "$STAGED_PYTHON_FILES" &>$ISORT_OUTPUT; then
|
||||||
isort $STAGED_PYTHON_FILES &>$ISORT_OUTPUT
|
isort "$STAGED_PYTHON_FILES" &>$ISORT_OUTPUT
|
||||||
printf "Reformatted.\n"
|
printf "Reformatted.\n"
|
||||||
formatter_updated=1
|
formatter_updated=1
|
||||||
|
else
|
||||||
|
printf "OK\n"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -65,19 +65,18 @@ fi
|
||||||
printf "> flake8 ... "
|
printf "> flake8 ... "
|
||||||
|
|
||||||
if type flake8 &>/dev/null; then
|
if type flake8 &>/dev/null; then
|
||||||
if [ -z $STAGED_PYTHON_FILES ]; then
|
if [ -z "$STAGED_PYTHON_FILES" ]; then
|
||||||
printf "OK\n"
|
printf "OK\n"
|
||||||
else
|
else
|
||||||
FLAKE8_OUTPUT="/tmp/gc-flake8-output.log"
|
FLAKE8_OUTPUT="/tmp/gc-flake8-output.log"
|
||||||
touch $FLAKE8_OUTPUT
|
touch $FLAKE8_OUTPUT
|
||||||
flake8 $STAGED_PYTHON_FILES &>$FLAKE8_OUTPUT
|
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if ! flake8 "$STAGED_PYTHON_FILES" &>$FLAKE8_OUTPUT; then
|
||||||
printf "OK\n"
|
|
||||||
else
|
|
||||||
printf "FAIL\n"
|
printf "FAIL\n"
|
||||||
cat $FLAKE8_OUTPUT
|
cat $FLAKE8_OUTPUT
|
||||||
checker_dirty=1
|
checker_dirty=1
|
||||||
|
else
|
||||||
|
printf "OK\n"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue