git pre-receive hook to catch Ruby debugger statements and reject push
.======. | |
| INRI | | |
| | | |
| | | |
.========' '========. | |
| _ xxxx _ | | |
| /_;-.__ / _\ _.-;_\ | | |
| `-._`'`_/'`.-' | | |
'========.`\ /`========' | |
| | / | | |
|/-.( | | |
|\_._\ | | |
| \ \`;| | |
| > |/| | |
| / // | | |
| |// | | |
| \(\ | | |
| `` | | |
| | | |
| | | |
| | | |
| | | |
\\||| _ _\\| \// |//_ _ \// _ | |
^ `^`^ ^`` `^ ^` ``^^` `^^` `^ `^ | |
#!/usr/bin/env ruby | |
ascii_art_path = ('/usr/share/ascii-art/christ.txt') | |
def msg(message) | |
normal_message = %{ | |
############################################################# | |
#{message} | |
############################################################# | |
} | |
better_message = File.read(ascii_art_path) | |
normal_message = better_message | |
normal_message << message + "\n\n" | |
normal_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.") | |
puts msg("I didn't die for you to leave debuggers in your code.") | |
exit 1 | |
end |
_.--""-. | |
.--" `. | |
/ \ | |
: . ; | |
; : | | |
:: . :: : | |
::. .:' ':. ; | |
;::::' __.._ ::. : | |
/ __.g$$$$$$""gp.._'-._ | |
.'.g$$$$$$$$$P T$-.:""-/ | |
'-.T$$P`T$$P' ");|.-' | |
"T .- ,-' | |
l _, / ;\.-"\ | |
d$$bp. / ; `-. | |
T"--"T .' : \_, : | |
Y""- _.-" ' ; )' ;"-._ | |
.:b..gdP / / .' / "-. | |
/ 'T$$P" .' .' .' `. | |
_.-`. \ \ .' .-" \ | |
.' "-.)_ `.-" .-" ; | |
/ "-._.-" : | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment