Skip to content

Instantly share code, notes, and snippets.

@temochka
Created May 20, 2019 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save temochka/bf30842f943e2a6b40dfe865ca8e752d to your computer and use it in GitHub Desktop.
Save temochka/bf30842f943e2a6b40dfe865ca8e752d to your computer and use it in GitHub Desktop.
Print often changed files and dirs.
#!/usr/bin/env ruby
# pipe the following command into this script:
# git log --pretty=format: --name-only | most-changed-dirs
counts = Hash.new { |hash, k| hash[k] = 0 }
while (filename = gets)
next if filename.start_with?('@')
parts = filename.strip.split(File::SEPARATOR).reject(&:empty?)
2.upto(parts.size) do |i|
counts[parts.take(i+1).join(File::SEPARATOR)] += 1
end
end
counts.sort_by { |k, v| -v }.take(100).each do |filename, count|
puts " #{count}\t\t#{filename}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment