Skip to content

Commit

Permalink
something
Browse files Browse the repository at this point in the history
  • Loading branch information
tcob committed Apr 16, 2018
1 parent ddb4568 commit cfec236
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pre-commit
Original 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/.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} -a") unless changed_files.empty?

exit $CHILD_STATUS.to_s[-1].to_i

0 comments on commit cfec236

Please sign in to comment.