From 4ff97c8adcc3fa15b4dfb17ad49ddd04657d8298 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Mon, 26 Mar 2018 08:13:47 +0900 Subject: [PATCH] Skip clang-format when there is no candidates (#39) The format check currently lists up all the files tracked by git as an input for clang-format when there is no candidate. Signed-off-by: Jonghyun Park --- scripts/command/format | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/command/format b/scripts/command/format index aa67de7..a8560dc 100644 --- a/scripts/command/format +++ b/scripts/command/format @@ -29,10 +29,13 @@ for DIRECTORY_TO_BE_TESTED in $(find "${NNCC_PROJECT_PATH}" -name '.FORMATCHECKE done CANDIDATE_FILES=$(find "${DIRECTORIES_TO_BE_TESTED[@]}" -iname '*.h' -o -iname '*.cpp') -TRACKED_FILES=$(git ls-files $CANDIDATE_FILES) -if [[ -n "$TRACKED_FILES" ]]; then - "${CLANG_FORMAT}" -i $TRACKED_FILES +if [[ -n "$CANDIDATE_FILES" ]]; then + TRACKED_FILES=$(git ls-files $CANDIDATE_FILES) + + if [[ -n "$TRACKED_FILES" ]]; then + "${CLANG_FORMAT}" -i $TRACKED_FILES + fi fi DIFF=$(git -C "${NNCC_PROJECT_PATH}" diff) -- 2.7.4