Sha256: 8c028d04f5a63cdf8af3ff01ff92c9f00a3b346931e9912cf537d4ca5a48b966
Contents?: true
Size: 1.02 KB
Versions: 16
Compression:
Stored size: 1.02 KB
Contents
require 'pre-commit/checks/plugin' module PreCommit module Checks class Whitespace < Plugin def self.aliases [:white_space] end def files_filter(staged_files) if @list.map(&:name).include?("PreCommit::Checks::Rubocop") then staged_files.reject{|name| name =~ /\.rb$/ } else staged_files end end def files_string(staged_files) files_filter(staged_files).map{|file| "'#{file}'" }.join(" ") end def call(staged_files) errors = `git diff-index --check --cached HEAD -- #{files_string(staged_files)} 2>&1` return if $?.success? # Initial commit: diff against the empty tree object if errors =~ /fatal: bad revision 'HEAD'/ errors = `git diff-index --check --cached 4b825dc642cb6eb9a060e54bf8d69288fbee4904 -- 2>&1` return if $?.success? end errors end def self.description "Finds white space." end end end end
Version data entries
16 entries across 16 versions & 1 rubygems