Skip to content

Instantly share code, notes, and snippets.

@demental
Last active December 30, 2015 18:49
Show Gist options
  • Save demental/7869683 to your computer and use it in GitHub Desktop.
Save demental/7869683 to your computer and use it in GitHub Desktop.
Pre push hook to avoid focused: true pushed in repo
#!/usr/bin/env ruby
# vim: set syntax=ruby
flag = false
Dir.glob("spec/**/*_spec.rb") do |file|
results = `cat #{file} | grep -E "(\:focused => true)|(focused\: true)"`.split("\n").map { |r| r.sub(/^\+[\s\t]*/, '') }
if $? == 0
puts file
puts results.map { |r|
`grep -n "#{r}" #{file}`
}.join("")
puts "Please remove :focused => true from your tests before pushing"
flag = true
end
end
exit 1 if flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment