Skip to content

Instantly share code, notes, and snippets.

@trshafer
Created August 9, 2013 22:04
Show Gist options
  • Select an option

  • Save trshafer/6197684 to your computer and use it in GitHub Desktop.

Select an option

Save trshafer/6197684 to your computer and use it in GitHub Desktop.

Revisions

  1. trshafer created this gist Aug 9, 2013.
    13 changes: 13 additions & 0 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/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