Skip to content

Instantly share code, notes, and snippets.

@jay3126
Forked from yeban/pre-commit.sh
Created February 2, 2012 12:52
Show Gist options
  • Save jay3126/1723323 to your computer and use it in GitHub Desktop.
Save jay3126/1723323 to your computer and use it in GitHub Desktop.
Git pre-commit hook to remove stray debugger statements from your merb project.
#!/bin/sh
# Remove stray debugger statements from the modified files before committing
# get a list of added, modified, copied files
files=`git diff --cached --name-only --diff-filter=ACM`
# remove debugger lines
#
# 1. remove any line containing a debugger
# sed -i "/debugger/d" $files
#
# 2. remove lines that contains only a debugger
sed -i "/^\s*-*\s*debugger\s*$/d" $files
#
# 3. remove commented/un-commented lines that contain only a debugger
# sed -i "/^\s*#*\s*debugger\s*$/d" $files
# re-stage the modified files
git add $files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment