Skip to content
Snippets Groups Projects
Commit cb0f7d3c authored by Alexis Girault's avatar Alexis Girault
Browse files

ENH: Add pre-commit hook

parent b58ed9e9
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
#-----------------------------------------------------------------------------
# Define egrep-q
#-----------------------------------------------------------------------------
egrep-q() {
egrep "$@" >/dev/null 2>/dev/null
}
#-----------------------------------------------------------------------------
# Define Error and Exit
#-----------------------------------------------------------------------------
printErrorAndExit() {
echo 'pre-commit hook failure' 1>&2
echo '-----------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
}
#-----------------------------------------------------------------------------
# Check that development setup is up-to-date
#-----------------------------------------------------------------------------
lastSetupForDevelopment=$(git config --get setup.version || echo 0)
eval $(grep '^SetupForDevelopment_VERSION=' "${BASH_SOURCE%/*}/../../Utilities/SetupForDevelopment.sh")
test -n "$SetupForDevelopment_VERSION" || SetupForDevelopment_VERSION=0
if test $lastSetupForDevelopment -lt $SetupForDevelopment_VERSION; then
printErrorAndExit 'Developer setup in this work tree is out of date. Please re-run
./Utilities/SetupForDevelopment.sh
'
fi
......@@ -54,4 +54,4 @@ echo
# this script and/or hooks have been modified.
#-----------------------------------------------------------------------------
SetupForDevelopment_VERSION=1
git config hooks.SetupForDevelopment ${SetupForDevelopment_VERSION}
git config setup.version ${SetupForDevelopment_VERSION}
......@@ -27,25 +27,7 @@ cd "${BASH_SOURCE%/*}/../GitHooks"
#-----------------------------------------------------------------------------
# Populate ".git/hooks"
#-----------------------------------------------------------------------------
echo "Populating git hooks..."
git_dir=$(git rev-parse --git-dir)
cp * $git_dir/hooks
#-----------------------------------------------------------------------------
# Go to the project root directory
#-----------------------------------------------------------------------------
#cd "../.."
#-----------------------------------------------------------------------------
# Set up KWStyle hook
#-----------------------------------------------------------------------------
#echo "Setting up the KWStyle hook..."
#KWStyleConf="Utilities/KWStyle/iMSTK.kws.xml"
#KWStyleOverwriteConf="Utilities/KWStyle/iMSTKKWSOverwrite.txt"
#AssertFileExists $KWStyleConf
#AssertFileExists $KWStyleOverwriteConf
#git config hooks.KWStyle.conf $KWStyleConf
#git config hooks.KWStyle.overwriteRulesConf $KWStyleOverwriteConf
#git config hooks.KWStyle true
echo "Done."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment