From 61fbf0bc805bdc34a138e6038147bbad5bbf13aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 6 Oct 2018 15:45:32 +0200 Subject: [PATCH 1/2] typo --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8fcd1144..95d9305d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: From 9bc3355a2164e825ff0063fb46dcdf04e84c1d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 6 Oct 2018 15:50:49 +0200 Subject: [PATCH 2/2] pre-commit hook: fix shellcheck's SC2086 & SC2181 --- .pre-commit.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.pre-commit.sh b/.pre-commit.sh index e621b126..30f09eb9 100755 --- a/.pre-commit.sh +++ b/.pre-commit.sh @@ -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