Skip to content

Commit

Permalink
linting: make clang-format more stable
Browse files Browse the repository at this point in the history
Clang format can return "clang-format did not modify any files" - let's
support this string.
  • Loading branch information
drewdzzz committed Jan 23, 2024
1 parent 0c7a643 commit 370d554
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 370d554

Please sign in to comment.