2013-12-22 00:38:52 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# Installation: ln -s ../../precommit-hook.sh .git/hooks/pre-commit
|
|
|
|
|
2015-11-05 02:29:14 +01:00
|
|
|
warning()
|
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
echo "*** $1 ***"
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
2015-11-23 02:43:28 +01:00
|
|
|
if git status --porcelain "staging" | grep "^.[^ ]" &> /dev/null; then
|
|
|
|
warning "PLEASE ADD OR STASH YOUR CHANGES IN staging"
|
2015-11-05 02:29:14 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if git status --porcelain "patches" | grep -v "^.\\?.*\\.py$" | grep "^.[^ ]" &> /dev/null; then
|
|
|
|
warning "PLEASE ADD OR STASH YOUR CHANGES IN patches"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-09-27 16:28:26 +02:00
|
|
|
|
2013-12-22 00:38:52 +01:00
|
|
|
git diff --cached --name-status | while read status file; do
|
2015-11-23 02:43:28 +01:00
|
|
|
if [[ "$file" =~ ^patches/ ]] || [[ "$file" =~ ^staging/ ]]; then
|
2015-11-05 02:29:14 +01:00
|
|
|
warning "UPDATING AUTOGENERATED FILES"
|
2015-11-23 02:43:28 +01:00
|
|
|
./staging/patchupdate.py || exit 1
|
2013-12-22 00:38:52 +01:00
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|