Last active
April 15, 2016 14:41
-
-
Save zenchild/6c65eb1234a381be609a to your computer and use it in GitHub Desktop.
Git pre-commit to check for mistakes
This file contains hidden or 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
#!/usr/bin/env bash | |
# vi:syntax=sh | |
check_for="(binding.pry|byebug)" | |
ignore_files="(Gemfile|Gemfile.lock)" | |
files_to_check=$(git diff-index --name-only HEAD -- | grep -Ev "^${ignore_files}$") | |
matches=$(grep -E "${check_for}" $files_to_check) | |
if [ ! -z "${matches}" ]; then | |
echo "========================================================================" | |
echo "Bad commit matches:" | |
echo "${matches}" | |
echo "Aborting commit!" | |
echo "========================================================================" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment