Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- files = []
- waiting = true
- threads = []
- lines = []
- ignore = [
- 'db/schema.rb'
- ]
- files += `git diff --name-only --cached`.split("\n")
- if files.size.zero?
- puts 'no files staged'
- exit 1
- end
- files.reject! { |x| ignore.include?(x) }
- puts 'Checking changes'
- files.each do |file|
- puts file
- end
- exit 0 if files.size.zero?
- threads << Thread.new do
- index = 0
- chars = %w[| / - \\]
- while waiting
- print "codeclimate analyzing ... #{chars[(index += 1) % chars.length]}\r"
- sleep(1)
- end
- puts 'codeclimate analyzing ... done'
- end
- threads << Thread.new do
- lines = %x(codeclimate analyze #{files.join(' ')})
- waiting = false
- end
- threads.map(&:join)
- lines.split("\n").each { |l| puts(l) }
- exit true if lines.include?('Found 0 issues')
- # Open input from keyboard usin IO.new(0) normal standard in is closed
- fd = IO.sysopen "/dev/tty", "r"
- ios = IO.new(fd, "r")
- print 'Do you want to commit anyway?(Y) '
- exit ios.gets.chomp == 'Y'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement