Skip to content

Instantly share code, notes, and snippets.

@natlownes
Created September 30, 2010 15:52
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 natlownes/604800 to your computer and use it in GitHub Desktop.
Save natlownes/604800 to your computer and use it in GitHub Desktop.
# git pre-receive hook for rejecting ruby code with debugger statements
#!/usr/bin/env ruby
def msg(message)
%{
#############################################################
#{message}
#############################################################
}
end
rev_old, rev_new, ref = STDIN.read.split(" ")
incoming = `git diff -U0 -p #{rev_old} #{rev_new}`
lines = incoming.split("\n")
regex = Regexp.new('^\+{1}.*debugger.*')
debugger_exists = lines.detect { |str| str.match(regex) }
if debugger_exists
puts msg("You've left a debugger in. Please remove and re-push.")
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment