Skip to content

Instantly share code, notes, and snippets.

@kitop
Last active January 2, 2016 13:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitop/8311448 to your computer and use it in GitHub Desktop.
Save kitop/8311448 to your computer and use it in GitHub Desktop.
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