Sha256: 5a4f22dafa27750406fc1e1bb95b3171af1a7f835bb2f462604877405216661e

Contents?: true

Size: 693 Bytes

Versions: 2

Compression:

Stored size: 693 Bytes

Contents

#!/usr/bin/env ruby
# Code modified from: https://gist.github.com/hanloong/9849098
require 'English'

ADDED = %r{A|AM}

changed_files = `git status --porcelain`.split(%r{\n})
changed_files = changed_files.select do |file_name_with_status|
  file_name_with_status =~ ADDED
end
changed_files = changed_files.map do |file_name_with_status|
  file_name_with_status.split(' ')[1]
end
changed_files = changed_files.select { |file_name|
  File.extname(file_name) == '.rb'
}.join(' ')

system("bundle exec rubocop -a #{changed_files}") unless changed_files.empty?

if $CHILD_STATUS.to_s[-1].to_i.zero? && !changed_files.empty?
  system("git add #{changed_files}")
end
exit $CHILD_STATUS.to_s[-1].to_i

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-resource_api-1.3.0 contrib/pre-commit
puppet-resource_api-1.2.0 contrib/pre-commit