Skip to content

Instantly share code, notes, and snippets.

@dinhhuydh
Last active August 26, 2018 12:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinhhuydh/b4b2ac75b4dd2807c39127e254f25e31 to your computer and use it in GitHub Desktop.
Save dinhhuydh/b4b2ac75b4dd2807c39127e254f25e31 to your computer and use it in GitHub Desktop.
# added to .git-hooks/pre_commit/debugger.rb
module Overcommit::Hook::PreCommit
# Check for Debugger
class Debugger < Base
def run
keywords = config['keywords']
result = execute(command, args: [keywords.join('|')] + applicable_files)
unless result.stdout.empty?
extract_messages(
result.stdout.split("\n"),
/^(?<file>(?:\w:)?[^:]+):(?<line>\d+)/,
lambda { |_type| :warning }
)
return :fail, "Debugger detected:\n#{result.stdout}"
end
:pass
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment