-
-
Save doubleotoo/2654931 to your computer and use it in GitHub Desktop.
git pre-receive hook to catch Ruby debugger statements and reject push
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.======. | |
| INRI | | |
| | | |
| | | |
.========' '========. | |
| _ xxxx _ | | |
| /_;-.__ / _\ _.-;_\ | | |
| `-._`'`_/'`.-' | | |
'========.`\ /`========' | |
| | / | | |
|/-.( | | |
|\_._\ | | |
| \ \`;| | |
| > |/| | |
| / // | | |
| |// | | |
| \(\ | | |
| `` | | |
| | | |
| | | |
| | | |
| | | |
\\||| _ _\\| \// |//_ _ \// _ | |
^ `^`^ ^`` `^ ^` ``^^` `^^` `^ `^ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.--""-. | |
.--" `. | |
/ \ | |
: . ; | |
; : | | |
:: . :: : | |
::. .:' ':. ; | |
;::::' __.._ ::. : | |
/ __.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