From 63fb239c7c59dac35713cc75448f4d8942144b6c Mon Sep 17 00:00:00 2001 From: Andrey Saranchin Date: Tue, 23 Jan 2024 22:10:10 +0300 Subject: [PATCH] linting: make clang-format more stable Clang format can return "clang-format did not modify any files" - let's support this string. --- .githooks/pre-commit | 2 +- .github/workflows/linting.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 9a70adc63..81347f6fd 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -6,7 +6,7 @@ set -eu -o pipefail exec 1>&2 output=$(git clang-format --diff --staged) -if [[ "$output" != "" && "$output" != "no modified files to format" ]]; then +if [[ "$output" != "" && "$output" != "no modified files to format" && "$output" != "clang-format did not modify any files" ]]; then echo Code formatting changed some files, please review. exit 1 fi diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 5f4450c2f..60fcbb54c 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -19,7 +19,7 @@ jobs: # Run clang-format on commits off the base branch of the pull request. run: | output=$(git clang-format origin/${{ github.event.pull_request.base.ref }} --diff) - if [[ "$output" != "" && "$output" != "no modified files to format" ]]; then + if [[ "$output" != "" && "$output" != "no modified files to format" && "$output" != "clang-format did not modify any files" ]]; then echo "$output" echo Code formatting changed some files, please review. exit 1