Skip to content

Instantly share code, notes, and snippets.

@vderyagin
Created November 19, 2012 08:25
Show Gist options
  • Save vderyagin/4109561 to your computer and use it in GitHub Desktop.
Save vderyagin/4109561 to your computer and use it in GitHub Desktop.
git churn
#! /usr/bin/env ruby
IO.popen('git log --name-only --pretty=format:""')
.readlines
.map(&:chomp)
.reject(&:empty?)
.select { |file| File.exists?(File.expand_path(file, ENV['GIT_WORK_TREE'])) }
.each_with_object(Hash.new(0)) { |file, changes| changes[file] += 1 }
.to_a
.sort_by(&:last)
.reverse_each { |file, churn| puts "#{churn.to_s.ljust 5} #{file}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment