1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#! /bin/sh
diff_files=`git diff --cached --name-only | grep -E '\.cxx$|\.hxx$|\.h$' `
if [ "$(uname)" == "Darwin" ]; then
clangFile=.githooks/clangFormatMac
if [ -f "$clangFile" ]; then
echo "clangFormat already downloaded."
else
curl -o .githooks/clangFormatMac https://data.kitware.com/api/v1/file/5d274e88877dfcc902effc47/download
chmod u+x .githooks/clangFormatMac
fi
for file in $diff_files; do
.githooks/clangFormatMac -style=file -i --verbose $file;
done
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
clangFile=.githooks/clangFormatLinux
if [ -f "$clangFile" ]; then
echo "clangFormat already downloaded."
else
curl -o .githooks/clangFormatLinux https://data.kitware.com/api/v1/file/5d2b8c87877dfcc902fda594/download
chmod u+x .githooks/clangFormatLinux
fi
for file in $diff_files; do
.githooks/clangFormatLinux -style=file -i --verbose $file;
done
else
clangFile=.githooks/clangFormatWindows.exe
if [ -f "$clangFile" ]; then
echo "clangFormat already downloaded."
else
curl -o .githooks/clangFormatWindows.exe https://data.kitware.com/api/v1/file/5d2b8775877dfcc902fd8236/download
fi
for file in $diff_files; do
.githooks/clangFormatWindows.exe -style=file -i --verbose $file;
done
fi
git status
|