class MaxFileSizeHook
This hook checks the size of each individual file against a configurable maximum size. Once a huge file is in your git history it can't be fully removed without rewriting history, so you're usually better off preventing them in the first place.
Constants
- DEFAULT_MAX_FILE_SIZE
- VERBOSE
Public Class Methods
new(max_size = DEFAULT_MAX_FILE_SIZE)
click to toggle source
# File lib/ruby_git_hooks/max_file_size.rb, line 14 def initialize(max_size = DEFAULT_MAX_FILE_SIZE) @max_file_size = max_size end
Public Instance Methods
check()
click to toggle source
# File lib/ruby_git_hooks/max_file_size.rb, line 18 def check STDERR.puts "Checking, max file size: #{@max_file_size}" if VERBOSE okay = true file_contents.each do |name, file| STDERR.puts "File length: #{file.length}" if VERBOSE if file.length > @max_file_size okay = false STDERR.puts "File #{name} exceeds maximum allowed size!" end end okay end