Skip to content

Instantly share code, notes, and snippets.

@xy124
Created December 23, 2017 19:52
Show Gist options
  • Save xy124/c7274555655a315b07fa59da31ef0601 to your computer and use it in GitHub Desktop.
Save xy124/c7274555655a315b07fa59da31ef0601 to your computer and use it in GitHub Desktop.
pre-commit hook that checks the format of all files to be committed
#!/bin/bash
p=`git rev-parse --show-toplevel`
cd $p
files=$(git status --porcelain | grep '^M ' | cut -d ' ' -f 3)
for i in $files
do
uncrustify --check -l C -c bin/parflow.cfg $i
RESULT=$?
if [ "$RESULT" != "0" ]; then
echo $RESULT
exit $RESULT
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment