mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 07:37:21 +02:00
format-check: Optimize format-check.sh
This commit silences the standard output of wget to generate less noise when using `format-check.sh` as a pre-commit hook. It also doesn't redownload the file over and over again but only when changes were detected. Previous behavior was wget creating numbered versions by multiple downloads, thus it always used the first version which was download. That is obviously wrong. It errors out nicely now when the download failed. Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
parent
22a90a73ef
commit
f041ba2281
@ -1,14 +1,18 @@
|
||||
#!/bin/bash
|
||||
# Simple script to check for clang-format compliance
|
||||
wget https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format
|
||||
chmod +x git-clang-format
|
||||
|
||||
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:"
|
||||
echo "${CLANG_FORMAT_OUTPUT}"
|
||||
exit 1
|
||||
wget -Nq https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format
|
||||
|
||||
if chmod +x git-clang-format; then
|
||||
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:"
|
||||
echo "${CLANG_FORMAT_OUTPUT}"
|
||||
exit 1
|
||||
else
|
||||
echo "Passed clang format check"
|
||||
fi
|
||||
else
|
||||
echo "Passed clang format check"
|
||||
echo "git-clang-format not downloaded"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user