Skip to content

Instantly share code, notes, and snippets.

@trshafer
Created August 9, 2013 22:04
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 trshafer/6197684 to your computer and use it in GitHub Desktop.
Save trshafer/6197684 to your computer and use it in GitHub Desktop.
pre-commit
#!/usr/bin/env ruby
# do not check in code with <<<<< nor debugger
diff_contents = `git diff --cached --unified=0 --diff-filter=AM -z HEAD`
bad_commit_text = diff_contents =~ /^\+(<{3,}|(\s*|.*;\s*)debugger)/
abort "Aborting: Found debugger or <<< in commit diff." if bad_commit_text
# looks for text in reminders.txt
reminder_location = 'ignored/reminders.txt'
file_location = File.join( File.dirname(__FILE__), '..', '..', reminder_location)
if File.exists?(file_location) && IO.readlines(file_location).join('').strip != ''
abort "Aborting: reminders.txt not satisfied."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment