Last active
April 8, 2018 02:14
Revisions
-
joeyAghion revised this gist
Aug 14, 2014 . 1 changed file with 19 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,23 @@ #!/usr/bin/env ruby # Adapted from https://gist.github.com/hanloong/9849098 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_with_status.split(' ')[1] } .select { |file_name| File.extname(file_name) == '.rb' }.join(' ') system("rubocop --force-exclusion #{changed_files}") unless changed_files.empty? exit $CHILD_STATUS.to_s[-1].to_i -
joeyAghion created this gist
Aug 14, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #!/usr/bin/env ruby require 'english' require 'rubocop' ADDED_OR_MODIFIED = /A|AM|M|^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_with_status.split(' ')[1] }. select { |file_name| File.extname(file_name) == '.rb' }.join(' ') system("rubocop #{changed_files}") unless changed_files.empty? exit $CHILD_STATUS.to_s[-1].to_i