Skip to content

Instantly share code, notes, and snippets.

@yeban
Created May 6, 2011 09:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save yeban/958687 to your computer and use it in GitHub Desktop.
Save yeban/958687 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
@svs
Copy link

svs commented Feb 2, 2012

useful!

@yeban
Copy link
Author

yeban commented Feb 2, 2012

Can't imagine anyone else needing this script, Sid :-|.

@svs
Copy link

svs commented Feb 2, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment