-
-
Save rikas/c7e3e7ccbcd272c35668 to your computer and use it in GitHub Desktop.
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 | |
## | |
# This file must be renamed to pre-commit without extension and | |
# added to your .git/hooks directory | |
# After that, run `chmod 755 pre-commit` to make it executable | |
$user = ENV['USER'] | |
def added_line_regex(string) | |
/^[+].*#{string}.*$/ | |
end | |
def stop_commit(message) | |
puts message | |
exit 1 | |
end | |
def has_biding_pry?(diff) | |
(diff =~ added_line_regex('binding.pry')) != nil | |
end | |
stop_commit("#{$user} has left a binding.pry in the code!") if has_biding_pry?(`git diff --cached`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment