Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ 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) || true ;# avoid failures if nothing is greped
if [ "$COMMIT_FILES" == "" ]; then
exit 0 ;# nothing to check
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
fi