-
-
Save taichiman/54cedb27435ae0ec822a to your computer and use it in GitHub Desktop.
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 | |
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze | |
changed_files = `git status --porcelain`.split(/\n/) | |
changed_files = changed_files.select { |f| f =~ ADDED_OR_MODIFIED } | |
changed_files = changed_files.map { |f| f.split(" ")[1] } | |
changed_files = changed_files.select { |file_name| File.extname(file_name) == ".rb" } | |
changed_files = changed_files.join(" ") | |
exit(0) if changed_files.empty? | |
success = system(%( | |
bundle exec rubocop #{changed_files} -c .rubocop_strict.yml | |
)) | |
STDIN.reopen('/dev/tty') | |
if success == false | |
puts "Would you like to continue press 'any key' or 'n/N' to halt? " | |
exit(1) if %w(N n).include?(gets.chomp) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment