Files
MySensors/hooks/install-hooks.sh
T
Patrick Fallberg 6564daec3e Update the pre-commit git hook (#667)
It now supports both Linux and Windows and checks
both coding style (astyle) and does static code
analysis (cppcheck).
Tested using "Bash on Ubuntu on Windows" and the
git shell (via GitHub for Windows).

Installation is done by executing hooks/install-hooks.sh
Windows users has to execute it in a cygwin based git shell.

Tools:
astyle (2.05.1 or newer)
cppcheck (1.76.1 or newer)
2016-11-28 14:57:26 -08:00

22 lines
710 B
Bash
Executable File

#!/bin/bash
PRECOMMIT=hooks/pre-commit
GITROOT=$(git rev-parse --git-dir)
if [[ "$OSTYPE" == "linux-gnu" ]]; then
rm -f $GITROOT/$PRECOMMIT
ln -s ../../$PRECOMMIT.sh $GITROOT/$PRECOMMIT
elif [[ "$OSTYPE" == "darwin"* ]]; then
rm -f $GITROOT/$PRECOMMIT
ln -s ../../$PRECOMMIT.sh $GITROOT/$PRECOMMIT
elif [[ "$OSTYPE" == "cygwin" ]]; then
rm -f $GITROOT/$PRECOMMIT
cp $GITROOT/../$PRECOMMIT.sh $GITROOT/$PRECOMMIT
elif [[ "$OSTYPE" == "msys" ]]; then
rm -f $GITROOT/$PRECOMMIT
cp $GITROOT/../$PRECOMMIT.sh $GITROOT/$PRECOMMIT
elif [[ "$OSTYPE" == "freebsd"* ]]; then
rm -f $GITROOT/$PRECOMMIT
ln -s ../../$PRECOMMIT.sh $GITROOT/$PRECOMMIT
else
echo "Unknown/unsupported OS, won't install anything"
fi