mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
If a change is not added to an origin/master branch, an argument can be used to specify the relevant branch name for the clang-format comparison. Change-Id: I8ce712d077bf4d048a04a29c12bc2cb45e4abb93 Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
20 lines
658 B
Bash
Executable File
20 lines
658 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Arg used to specify non-'origin/master' comparison branch
|
|
ORIGIN_BRANCH=${1:-"origin/master"}
|
|
|
|
# Run git-clang-format to check for violations
|
|
if [ "$TRAVIS" == "true" ]; then
|
|
EXTRA_OPTS="--binary `which clang-format-9`"
|
|
fi
|
|
CLANG_FORMAT_OUTPUT=$(git-clang-format --diff $ORIGIN_BRANCH --extensions c,cpp,h,hpp $EXTRA_OPTS)
|
|
|
|
# Check for no-ops
|
|
grep '^no modified files to format$' <<<"$CLANG_FORMAT_OUTPUT" && exit 0
|
|
grep '^clang-format did not modify any files$' <<<"$CLANG_FORMAT_OUTPUT" && exit 0
|
|
|
|
# Dump formatting diff and signal failure
|
|
echo -e "\n==== FORMATTING VIOLATIONS DETECTED ====\n"
|
|
echo "$CLANG_FORMAT_OUTPUT"
|
|
exit 1
|