Skip to content

Instantly share code, notes, and snippets.

@kenton
Created June 30, 2014 17:34
Show Gist options
  • Save kenton/7dd74a377e5448c1e904 to your computer and use it in GitHub Desktop.
Save kenton/7dd74a377e5448c1e904 to your computer and use it in GitHub Desktop.
git precommit hook
#!/usr/bin/env ruby
# exit 0 means "all good"
todo = `git diff --staged | ack KGNTODO`
open_page = `git diff --staged | ack save_and_open_page`
pry = `git diff --staged | ack 'binding.pry'`
remote_pry = `git diff --staged | ack 'binding.remote_pry'`
if todo.empty? and pry.empty? and remote_pry.empty? and open_page.empty?
error = false
else
error = true
end
puts "todo: #{todo}"
puts "save_and_open_page: #{open_page}"
puts "pry: #{pry}"
puts "remote_pry: #{remote_pry}"
puts "errors?: #{error}"
exit 1 if error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment