Skip to content

Instantly share code, notes, and snippets.

@stupidpupil
Last active September 1, 2016 00:32
Show Gist options
  • Save stupidpupil/2a42b19f6e93ea0a52e93b7497558499 to your computer and use it in GitHub Desktop.
Save stupidpupil/2a42b19f6e93ea0a52e93b7497558499 to your computer and use it in GitHub Desktop.
Beancount git pre-commit hook
#!/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