Skip to content

Instantly share code, notes, and snippets.

@stephan-buckmaster
Created June 28, 2018 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephan-buckmaster/14e3ec39ab6640e31204c9bc63f3dc42 to your computer and use it in GitHub Desktop.
Save stephan-buckmaster/14e3ec39ab6640e31204c9bc63f3dc42 to your computer and use it in GitHub Desktop.
Pre-commit hook to remind committer to run rake-assets-precompile
#!/bin/bash
#
# if changed assets are being committed, prompt the user to confirm
# they have precompiled assets.
if test $(git diff --cached --name-only | grep app/assets | wc -l) != 0
then
# grab user input
exec < /dev/tty
echo "Assets have changed. Have you performed rake assets:precompile?"
read -p "Continue commit (Yes/No)?" choice
echo "Received answer $choice"
if [ "$choice" == "Yes" ]; then
exit 0
else
echo "Abandoning commit"
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment