Sha256: 5045aca0c71cb66ac737a7934e924f079e3499b586c3781f6ad812ef1a26d8f7
Contents?: true
Size: 584 Bytes
Versions: 6
Compression:
Stored size: 584 Bytes
Contents
module PreCommit module Utils module StagedFiles def staged_files @staged_files ||= begin files = `git diff --cached --name-only --diff-filter=ACM`.split files.reject { |f| size = File.size(f); size > 1_000_000 || (size > 20 && binary?(f)) } end end private # from https://github.com/djberg96/ptools/blob/master/lib/ptools.rb#L90 def binary?(file) s = (File.read(file, File.stat(file).blksize) || "").split(//) ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30 end end end end
Version data entries
6 entries across 6 versions & 1 rubygems