From 380fa917d3034ace8552299c4de68e44ef04648e Mon Sep 17 00:00:00 2001 From: Marc Vef Date: Thu, 26 Nov 2020 13:26:43 +0100 Subject: [PATCH] Added c++17 support to clang-format + added verbose mode --- .clang-format | 2 +- .gitlab-ci.yml | 2 +- scripts/check_format.sh | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.clang-format b/.clang-format index e04649874..8e3945de2 100644 --- a/.clang-format +++ b/.clang-format @@ -68,6 +68,6 @@ SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: c++14 +Standard: c++17 TabWidth: 4 UseTab: Never diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 73badb0a6..1ed082493 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ image: gekkofs/gekkofs:build_env-0.8.0 check format: stage: check format script: - - ${CI_PROJECT_DIR}/scripts/check_format.sh -s "${CI_PROJECT_DIR}/src" -i "${CI_PROJECT_DIR}/src" + - ${CI_PROJECT_DIR}/scripts/check_format.sh -s "${CI_PROJECT_DIR}/src" -i "${CI_PROJECT_DIR}/src" -v compile dependencies: stage: build deps diff --git a/scripts/check_format.sh b/scripts/check_format.sh index d58c045b7..c178ebc38 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -4,6 +4,7 @@ PROJECT_SRC="$(pwd)/src" PROJECT_INCLUDE="$(pwd)/include" RUN_FORMAT=false CLANG_FORMAT_BIN="" +VERBOSE=false usage_short() { echo " @@ -30,6 +31,7 @@ optional arguments: (default: looks for 'clang-format' or 'clang-format-10') -r, --run_format run clang-formatter before formatting check DISCLAIMER: FILES ARE MODIFIED IN PLACE! + -v, --verbose shows the diff of all files " } @@ -61,6 +63,10 @@ while [[ $# -gt 0 ]]; do RUN_FORMAT=true shift # past argument ;; + -v | --verbose) + VERBOSE=true + shift # past argument + ;; -h | --help) help_msg exit @@ -115,6 +121,11 @@ while IFS= read -r -d '' FILE; do else echo -n "$FILE " echo "$UNFORMATTED_LINES" + if [[ "$VERBOSE" == true ]]; then + diff -u <(cat "$FILE") <($CLANG_FORMAT_BIN -style=file "$FILE") + echo "_______________________________________________________" + fi + echo FAIL=true fi fi -- GitLab