From b6e3a4719a8614403e4930da2c12108676fdcbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 15 Dec 2020 12:14:52 +0100 Subject: [PATCH 1/6] Avoid problem if no file is a c++ file --- .github/workflows/format.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index bc3fb9696a..09ffe27f0b 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -16,11 +16,15 @@ jobs: git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }} BASE_COMMIT=$(git rev-parse ${{ github.event.pull_request.base.sha }}) COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT} | grep -E -- '\.cxx|\.h' | grep -i -v LinkDef) + if [ $? -eq 1 ]; then + exit 0 ;# no files to be checked + fi + RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES}) if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then - exit 0 + exit 0 ;# all good else git-clang-format-8 --commit $BASE_COMMIT --diff --binary $(which clang-format-8) echo "$RESULT_OUTPUT" exit 1 - fi \ No newline at end of file + fi From be65c79be9213004d08c797ba0467d83a9132e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 15 Dec 2020 12:25:22 +0100 Subject: [PATCH 2/6] test --- .github/workflows/format.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 09ffe27f0b..9c68650fae 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -15,12 +15,12 @@ jobs: git fetch origin ${{ github.event.pull_request.base.ref }} git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }} BASE_COMMIT=$(git rev-parse ${{ github.event.pull_request.base.sha }}) - COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT} | grep -E -- '\.cxx|\.h' | grep -i -v LinkDef) + COMMIT_FILES_=$(git diff --name-only ${BASE_COMMIT} | grep -E -- '\.cxx|\.h' | grep -i -v LinkDef) if [ $? -eq 1 ]; then exit 0 ;# no files to be checked fi - RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES}) + RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES_}) if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then exit 0 ;# all good else From 55b966b87c7f90633709e874a53ddc75f2fece08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 15 Dec 2020 12:29:25 +0100 Subject: [PATCH 3/6] Update format.yml --- .github/workflows/format.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 9c68650fae..37f3a456b2 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -15,12 +15,14 @@ jobs: git fetch origin ${{ github.event.pull_request.base.ref }} git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }} BASE_COMMIT=$(git rev-parse ${{ github.event.pull_request.base.sha }}) - COMMIT_FILES_=$(git diff --name-only ${BASE_COMMIT} | grep -E -- '\.cxx|\.h' | grep -i -v LinkDef) + COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT}) + echo "between" + COMMIT_FILES_FILTERED=$(echo ${COMMIT_FILES} | grep -E -- '\.cxx|\.h' | grep -i -v LinkDef) if [ $? -eq 1 ]; then exit 0 ;# no files to be checked fi - - RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES_}) + echo "after" + RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES_FILTERED}) if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then exit 0 ;# all good else From baeefb111549098113df19b83733ee6af062364f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 15 Dec 2020 12:30:43 +0100 Subject: [PATCH 4/6] Update format.yml --- .github/workflows/format.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 37f3a456b2..c5fe5a74a9 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -18,6 +18,7 @@ jobs: COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT}) echo "between" COMMIT_FILES_FILTERED=$(echo ${COMMIT_FILES} | grep -E -- '\.cxx|\.h' | grep -i -v LinkDef) + echo "between2" if [ $? -eq 1 ]; then exit 0 ;# no files to be checked fi From 2a6f9e157c1a6d599881c1f478b92d88305a31ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 15 Dec 2020 12:40:40 +0100 Subject: [PATCH 5/6] Update format.yml --- .github/workflows/format.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index c5fe5a74a9..82c632c2fe 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -15,15 +15,13 @@ jobs: git fetch origin ${{ github.event.pull_request.base.ref }} git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }} BASE_COMMIT=$(git rev-parse ${{ github.event.pull_request.base.sha }}) - COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT}) - echo "between" - COMMIT_FILES_FILTERED=$(echo ${COMMIT_FILES} | grep -E -- '\.cxx|\.h' | grep -i -v LinkDef) - echo "between2" - if [ $? -eq 1 ]; then - exit 0 ;# no files to be checked + COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT} | grep -E -- '\.cxx|\.h' | grep -i -v LinkDef) || true ;# avoid failures if nothing is greped + if [ "$COMMIT_FILES" == "" ]; then + exit 0 ;# nothing to check fi + echo "after" - RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES_FILTERED}) + RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES}) if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then exit 0 ;# all good else From b73028a049d048fbfd758d1280b54b4e12bdcd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 15 Dec 2020 12:42:40 +0100 Subject: [PATCH 6/6] Update format.yml --- .github/workflows/format.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 82c632c2fe..abb394ea4e 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -20,7 +20,6 @@ jobs: exit 0 ;# nothing to check fi - echo "after" RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES}) if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then exit 0 ;# all good