mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 07:37:21 +02:00
format-check: Enable usage as pre-commit hook
This adds support for a switch `--pre-commit` to work in pre-commit-mode. It downloads the file and runs the real pre-commit-hook then. Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
parent
f041ba2281
commit
a8726e8959
@ -1,9 +1,18 @@
|
||||
#!/bin/bash
|
||||
# Simple script to check for clang-format compliance
|
||||
|
||||
# Ensure we are at the project root
|
||||
cd "$(dirname $0)"/..
|
||||
|
||||
wget -Nq https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format
|
||||
|
||||
if chmod +x git-clang-format; then
|
||||
if [[ "$1" == "--pre-commit" ]]; then
|
||||
# used via .git/hooks/pre-commit:
|
||||
# exec "$(dirname $0)"/../../scripts/format-check.sh --pre-commit
|
||||
./git-clang-format
|
||||
exit
|
||||
fi
|
||||
CLANG_FORMAT_OUTPUT=$(./git-clang-format HEAD^ HEAD --diff)
|
||||
if [[ ! ${CLANG_FORMAT_OUTPUT} == "no modified files to format" ]] && [[ ! -z ${CLANG_FORMAT_OUTPUT} ]]; then
|
||||
echo "Failed clang format check:"
|
||||
|
Loading…
x
Reference in New Issue
Block a user