Skip to content

Commit

Permalink
scripts: Fix clangfmt script when not found any modified files
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMazur committed Mar 5, 2024
1 parent 8d4d598 commit ad29a01
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/clangfmt
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ fi
if [ "$#" -gt 0 ]; then
"$clang_format" --style=file "$opts" "$@"
elif [[ "$CHECK_MODIFIED_ONLY" == "1" ]]; then
# exit early with 0 if no modified files found
git diff --name-only main | \
grep -E '.*\.(c|h|cpp|hpp)$' | \
(grep -E '.*\.(c|h|cpp|hpp)$' || exit 0) | \
(xargs "$clang_format" --style=file "$opts" $err || die "C/C++ code formatting changes detected, Run '$0' to reformat.")

else
Expand Down

0 comments on commit ad29a01

Please sign in to comment.