Skip to content

Instantly share code, notes, and snippets.

@Kimtaro
Created August 28, 2015 11:21
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 Kimtaro/928996ca89e9bd576c09 to your computer and use it in GitHub Desktop.
Save Kimtaro/928996ca89e9bd576c09 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# https://gist.github.com/jvatic/2711625
flag = false
files = `git diff --cached --name-only --diff-filter=ACM | grep "_spec\.rb$"`.split("\n")
files.each do |file|
results = `git diff --cached #{file} | grep "^\+[^+]" | grep ":focus"`.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 from your tests before committing"
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