2013-12-21 15:38:52 -08:00
|
|
|
#!/bin/bash
|
|
|
|
# Installation: ln -s ../../precommit-hook.sh .git/hooks/pre-commit
|
|
|
|
|
2015-11-04 17:29:14 -08:00
|
|
|
warning()
|
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
echo "*** $1 ***"
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
2016-07-01 11:13:03 -07:00
|
|
|
if git status --porcelain "staging" | grep -q "^.[^ ]"; then
|
2015-11-22 17:43:28 -08:00
|
|
|
warning "PLEASE ADD OR STASH YOUR CHANGES IN staging"
|
2015-11-04 17:29:14 -08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-07-01 11:13:03 -07:00
|
|
|
if git status --porcelain "patches" | grep -v "^.\\?.*\\.py$" | grep -q "^.[^ ]"; then
|
2015-11-04 17:29:14 -08:00
|
|
|
warning "PLEASE ADD OR STASH YOUR CHANGES IN patches"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-09-27 07:28:26 -07:00
|
|
|
|
2016-07-01 11:13:03 -07:00
|
|
|
if ! git status --porcelain "staging/VERSION" | grep -q "^M."; then
|
2016-06-30 16:05:25 -07:00
|
|
|
perl -i -pe 's/(\d+)$/($1 + 1)." (unreleased)"/e' "staging/VERSION"
|
|
|
|
git add "staging/VERSION"
|
|
|
|
fi
|
|
|
|
|
2013-12-21 15:38:52 -08:00
|
|
|
git diff --cached --name-status | while read status file; do
|
2015-11-22 17:43:28 -08:00
|
|
|
if [[ "$file" =~ ^patches/ ]] || [[ "$file" =~ ^staging/ ]]; then
|
2015-11-04 17:29:14 -08:00
|
|
|
warning "UPDATING AUTOGENERATED FILES"
|
2015-11-22 17:43:28 -08:00
|
|
|
./staging/patchupdate.py || exit 1
|
2013-12-21 15:38:52 -08:00
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|