Skip to content

Instantly share code, notes, and snippets.

@kitop kitop/post-commit
Last active Jan 2, 2016

Embed
What would you like to do?
Git post commit hook to remind to precompile some assets
#!/bin/sh
#
# A hook script to remind us to precompile the assets.
color='\033[0;35m'
NC='\033[0m' # No Color
changes=$(git diff --name-only HEAD^)
echo $changes | grep ^app/assets > /dev/null
assets_changed=$?
echo $changes | grep ^public/assets > /dev/null
assets_precompiled=$?
# here we check if any asset changend, and if there are no precompiled assets
if [ $assets_changed -eq 0 -a $assets_precompiled -eq 1 ]; then
echo -e "${color}HEADS UP!${NC}"
echo "Seems you’ve changed some assets but didn’t add any precompiled ones."
echo "Don't forget to precompile them before deploying!"
echo "---------------------------------------------------------------------"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.