Skip to content

Instantly share code, notes, and snippets.

@addicted2sounds
Created March 23, 2018 16:49
Show Gist options
  • Save addicted2sounds/dac25dcccb5f93293e3c944835ff5fb9 to your computer and use it in GitHub Desktop.
Save addicted2sounds/dac25dcccb5f93293e3c944835ff5fb9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
}.
map { |file_name_with_status|
file_name_array = file_name_with_status.strip.split(' ')
file_name_array.shift
fname = file_name_array.join(' ')
fname[0]="" if fname[0] == '"'
fname[fname.length-1]="" if fname[fname.length-1] == '"'
fname
}.join(' ')
system("rubocop #{changed_files} --force-exclusion --parallel") unless changed_files.empty?
exit $CHILD_STATUS.to_s[-1].to_i%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment