Created
October 8, 2013 15:03
-
-
Save cris/6886138 to your computer and use it in GitHub Desktop.
Prevents commit of "focus: true"/":focus => true"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# vim: set syntax=ruby | |
flag = false | |
files = `git diff --cached --name-only --diff-filter=ACM | grep "_spec\.rb$"`.split("\n") | |
files.each do |file| | |
patterns = ["focus:[ ]*true", ":focus[ ]*=>[ ]*true"] | |
patterns.each do |pattern| | |
results = `git diff --cached #{file} | grep "^\+[^+]" | grep "#{pattern}"`.split("\n").map { |r| r.sub(/^\+[\s\t]*/, '') } | |
if $? == 0 | |
puts file | |
puts results.map { |r| | |
`grep -n "#{r}" #{file}` | |
}.join("") | |
puts "Please remove :focus => true from your tests before committing" | |
flag = true | |
end | |
end | |
end | |
exit 1 if flag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment