Skip to content

Instantly share code, notes, and snippets.

@richo
Created January 9, 2013 05:26
Show Gist options
  • Save richo/4490859 to your computer and use it in GitHub Desktop.
Save richo/4490859 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
FEATURE_THRESHOLD=0.2
totals = {
feature: 0,
maint: 0,
}
`git rev-list --no-merges 1e1690b..HEAD`.lines.each.with_index do |rev, idx|
rev = rev.chomp
added = 0
removed = 0
files = []
`git diff #{rev}^ --numstat`.lines.each do |line|
next if line.start_with? "-"
t_added, t_removed, t_file = line.split(/\s/)
next if t_file.start_with? "vendor"
files << t_file
added += t_added.to_i
removed += t_removed.to_i
totals[:added]
end
if removed == 0 || added / removed < FEATURE_THRESHOLD
totals[:feature] += added + removed
else
totals[:maint] += added + removed
end
# puts "Added #{added} Removed #{removed} Files #{files}"
puts "#{totals.inspect} #{Time.now.to_i}" if idx % 100 == 0
end
puts totals.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment