class CaseClashHook

This hook checks whether a similar file exists with the same name except for uppercase/lowercase. It's useful when Mac OS and Unix people need to coexist in a single Git repository. You can be sure that the Linux people can't check in files that the Mac people can neither see nor delete.

Public Instance Methods

check() click to toggle source
# File lib/ruby_git_hooks/case_clash.rb, line 12
def check
  downcase_hash = {}

  ls_files.map(&:strip).each do |filename|
    downcase_hash[filename.downcase] ||= []
    downcase_hash[filename.downcase].push filename
  end

  okay = true
  downcase_hash.each do |_, filenames|
    if filenames.length > 1
      okay = false
      STDERR.puts "Duplicate-except-case files detected: #{filenames.inspect}"
    end
  end

  okay
end