Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Examine files and review git history to determine what percentage of the files was written by a particular author
#!/usr/bin/env ruby
author = ARGV.shift
dir = ARGV.shift || "."
BlamedFile = Struct.new(:file, :lines, :blamed_lines, :percent)
files = []
all_files = Dir.glob("#{dir}/**/*")
puts "Examining #{all_files.size} files:"
all_files.each do |file|
next if File.directory?(file)
next unless File.readable?(file)
lines = File.readlines(file).size
next if lines == 0
print "."
$stdout.flush
blamed_lines = `git blame #{file} | grep "#{author}"`.split("\n").size
files << BlamedFile.new(file, lines, blamed_lines, blamed_lines / lines.to_f)
end
puts ""
files.sort_by{|f| f.percent}.reverse.each do |f|
next unless f.blamed_lines > 1
next unless f.lines > 10
puts "%3.0f%% of %d lines - %s" % [f.percent * 100, f.lines, f.file]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.