Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. FORBIDDEN = [
  4. /debugger/i,
  5. /fuck/i,
  6. /shit/i,
  7. /bitch/i,
  8. /wtf/i,
  9. /fmt.Println/i,
  10. /fmt.Printf/i,
  11. /console\.debug/i,
  12. /Lorem\.ipsum\.dolor\.sit\.amet/i,
  13. /do not commit/i,
  14. /donkey balls/i,
  15. /wtf d+/i,
  16. /fucking/i,
  17. /retarded/i,
  18. /blah/i
  19. ]
  20.  
  21. full_diff = `git diff --cached --`
  22.  
  23. full_diff.scan(%r{^\+\+\+ b/(.+)\n@@.*\n([\s\S]*?)(?:^diff|\z)}).each do |file, diff|
  24.  
  25. added = diff.split("\n").select { |x| x.start_with?("+") }.join("\n")
  26.  
  27. if FORBIDDEN.any? { |re| added.match(re) }
  28. puts "=============================================================================="
  29. puts "%{Hey dumbass, you have debug shit in your code! You cannot commit '#{$1 || $&}' to #{file}}"
  30. puts "YOLO? Use --no-verify"
  31. puts "=============================================================================="
  32. exit 1
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement