Output theme info

This commit is contained in:
Christian Mehlmauer
2013-12-07 20:51:30 +01:00
parent 4c4b363035
commit 2fd11cba15
6 changed files with 109 additions and 1 deletions

38
dev/pre-commit-hook.rb Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env ruby
# ln -sf <this file> /Users/xxx/wpscan/.git/hooks/pre-commit
require 'pty'
html_path = 'rspec_results.html'
begin
PTY.spawn( 'rspec spec --format h > rspec_results.html' ) do |stdin, stdout, pid|
begin
stdin.each { |line| print line }
rescue Errno::EIO
end
end
rescue PTY::ChildExited
puts 'Child process exit!'
end
# find out if there were any errors
html = open(html_path).read
examples = html.match(/(\d+) examples/)[0].to_i rescue 0
errors = html.match(/(\d+) errors/)[0].to_i rescue 0
if errors == 0 then
errors = html.match(/(\d+) failure/)[0].to_i rescue 0
end
pending = html.match(/(\d+) pending/)[0].to_i rescue 0
if errors.zero?
puts "0 failed! #{examples} run, #{pending} pending"
sleep 1
exit 0
else
puts "\aCOMMIT FAILED!!"
puts "View your rspec results at #{File.expand_path(html_path)}"
puts
puts "#{errors} failed! #{examples} run, #{pending} pending"
exit 1
end