Last active
September 1, 2016 00:32
-
-
Save stupidpupil/2a42b19f6e93ea0a52e93b7497558499 to your computer and use it in GitHub Desktop.
Beancount git pre-commit hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
git stash --quiet --keep-index --include-untracked | |
bean_check_err=`bean-check main.beancount 2>&1 >/dev/null` | |
git stash pop --quiet --index | |
error_lines=`printf "$bean_check_err" | wc -l | awk {'print $1'}` | |
if [ $error_lines -eq 0 ]; then | |
echo "\\033[32mBean-check passed! 💰\\033[0;39m" | |
exit 0 | |
fi | |
echo "\\033[1;31mBean-check failed! 🔥\\033[0;39m" | |
echo "" | |
echo "$bean_check_err" | |
echo "" | |
echo "\\033[1;31mBean-check failed! 🔥\\033[0;39m" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment