From c1a7f4f3de1c481aba1341d45b663a4058e4ebdd Mon Sep 17 00:00:00 2001 From: P-A Loizeau <p.-a.loizeau@gsi.de> Date: Thu, 3 Dec 2020 11:13:50 +0100 Subject: [PATCH] Add check on clang version in check and apply format scripts --- scripts/apply-format-changes.sh | 23 +++++++++++++++++------ scripts/check-format-changes.sh | 24 +++++++++++++++++------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/scripts/apply-format-changes.sh b/scripts/apply-format-changes.sh index c28640f3fd..76de85a7f2 100755 --- a/scripts/apply-format-changes.sh +++ b/scripts/apply-format-changes.sh @@ -1,13 +1,24 @@ +#!/bin/bash + +if [[ -z $GIT_CLANG_FORMAT_BIN || -z $CLANG_FORMAT_BIN ]]; then + echo "Error: GIT_CLANG_FORMAT_BIN or CLANG_FORMAT_BIN not defined" + echo "=> Please follow the instruction at https://redmine.cbm.gsi.de/projects/cbmroot/wiki/Clang-format" + exit -1 +fi + +# Check clang-format version +VERSION=$($CLANG_FORMAT_BIN --version) +if [[ "$VERSION" != *"11.0.0"* ]]; then + echo "Error: CLANG_FORMAT_BIN version not matching the standard cbmroot one (used in the MR test chain)" + echo "11.0.0 vs " $VERSION + echo "=> Please follow the instruction at https://redmine.cbm.gsi.de/projects/cbmroot/wiki/Clang-format" + exit -1 +fi + FAIRROOT_FORMAT_BASE=upstream/master BASE_COMMIT=${FAIRROOT_FORMAT_BASE:-HEAD} CHANGED_FILES=$(git diff --name-only $BASE_COMMIT | grep -E '.*\.(h|hpp|c|C|cpp|cxx|tpl)$' | grep -viE '.*LinkDef.h$') -if [ -z $GIT_CLANG_FORMAT_BIN ]; then - echo "Warning:" - echo "GIT_CLANG_FORMAT_BIN not defined, trying to use git-clang-format-10 if present" - echo "" - GIT_CLANG_FORMAT_BIN=git-clang-format-10 -fi $GIT_CLANG_FORMAT_BIN --verbose --commit $BASE_COMMIT $CHANGED_FILES --extensions h,hpp,c,C,cpp,cxx,tpl git add $CHANGED_FILES diff --git a/scripts/check-format-changes.sh b/scripts/check-format-changes.sh index f75d9d6642..046e2742e9 100755 --- a/scripts/check-format-changes.sh +++ b/scripts/check-format-changes.sh @@ -1,13 +1,23 @@ +#!/bin/bash + +if [[ -z $GIT_CLANG_FORMAT_BIN || -z $CLANG_FORMAT_BIN ]]; then + echo "Error: GIT_CLANG_FORMAT_BIN or CLANG_FORMAT_BIN not defined" + echo "=> Please follow the instruction at https://redmine.cbm.gsi.de/projects/cbmroot/wiki/Clang-format" + exit -1 +fi + +# Check clang-format version +VERSION=$($CLANG_FORMAT_BIN --version) +if [[ "$VERSION" != *"11.0.0"* ]]; then + echo "Error: CLANG_FORMAT_BIN version not matching the standard cbmroot one (used in the MR test chain)" + echo "clang-format version 11.0.0 vs " $VERSION + echo "=> Please follow the instruction at https://redmine.cbm.gsi.de/projects/cbmroot/wiki/Clang-format" + exit -1 +fi + git fetch upstream FAIRROOT_FORMAT_BASE=upstream/master BASE_COMMIT=${FAIRROOT_FORMAT_BASE:-HEAD} CHANGED_FILES=$(git diff --name-only $BASE_COMMIT | grep -E '.*\.(h|hpp|c|C|cpp|cxx|tpl)$' | grep -viE '.*LinkDef.h$') -if [ -z $GIT_CLANG_FORMAT_BIN ]; then - echo "Warning:" - echo "GIT_CLANG_FORMAT_BIN not defined, trying to use git-clang-format-10 if present" - echo "" - GIT_CLANG_FORMAT_BIN=git-clang-format-10 -fi - $GIT_CLANG_FORMAT_BIN --commit $BASE_COMMIT --diff $CHANGED_FILES --extensions h,hpp,c,C,cpp,cxx,tpl -- GitLab