Skip to content

Instantly share code, notes, and snippets.

@zenchild
Last active April 15, 2016 14:41
Show Gist options
  • Save zenchild/6c65eb1234a381be609a to your computer and use it in GitHub Desktop.
Save zenchild/6c65eb1234a381be609a to your computer and use it in GitHub Desktop.
Git pre-commit to check for mistakes
#!/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