0ad5fbd48d
Instead of hardcoding paths to the executables, use the version in the path. This allows the scripts to work on more systems, and allows the binary version to be changed more easily if needed. Signed-off-by: Martin Roth <martin@coreboot.org> Change-Id: Ifcc56aa21092cd3866eacb6a02d198110ec6051d Reviewed-on: https://review.coreboot.org/c/coreboot/+/48904 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
27 lines
739 B
Bash
Executable file
27 lines
739 B
Bash
Executable file
#!/usr/bin/env sh
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
# DESCR: Run clang-format on white-listed directories
|
|
|
|
LC_ALL=C export LC_ALL
|
|
|
|
# until we require this by default, we need a list of opted-in directories
|
|
if [ ! -f .clang-format-scope ]; then
|
|
exit 0
|
|
fi
|
|
|
|
files_to_check=$(git log HEAD~..HEAD --format= --name-only $(cat .clang-format-scope) |grep "\.[ch]$")
|
|
|
|
# nothing to do
|
|
if [ -z "$files_to_check" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [ $(clang-format $files_to_check | wc -l) -gt 0 ]; then
|
|
if [ "$(git diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff)" != "" ]; then
|
|
echo "Coding style mismatch. The following patch fixes it:"
|
|
git diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff
|
|
exit 0
|
|
fi
|
|
fi
|