Skip to content

Instantly share code, notes, and snippets.

@ocadaruma
Created June 15, 2017 14:24
Show Gist options
  • Save ocadaruma/ad5803e6939e264f9e6f09208a3e3a20 to your computer and use it in GitHub Desktop.
Save ocadaruma/ad5803e6939e264f9e6f09208a3e3a20 to your computer and use it in GitHub Desktop.
# Usage:
## cd /path/to/repository && ruby /path/to/repo_stat.rb
files = `git grep --cached -Il ''`.chomp.split("\n")
count_map = {}
files.each do |file|
ext = file.split(/[.\/]/).last
count = `cat #{file.gsub(" ", "\\ ")} | wc -l | tr -d ' '`.chomp.to_i
current = count_map[ext] || 0
count_map[ext] = current + count
end
count_map.sort_by { |k, v| -v }.each do |ext, count|
puts "#{ext}\t#{count}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment