Skip to content

Instantly share code, notes, and snippets.

@zzak
Last active December 17, 2015 11:29
Show Gist options
  • Save zzak/5602892 to your computer and use it in GitHub Desktop.
Save zzak/5602892 to your computer and use it in GitHub Desktop.
Commits by size
require 'git'
num_commits = 20000
sizes = {:s => 0, :m => 0, :l => 0, :xl => 0, :xxl => 0}
Git.open('.').log(num_commits).author('zzak').each do |commit|
log = `git show --numstat #{commit.sha}`
stat = 0
log.scan(/^(\d+)\t(\d+)/).flatten.each { |i| stat += i.to_i }
case stat
when 1..20
sizes[:s] += 1
when 20..50
sizes[:m] += 1
when 50..100
sizes[:l] += 1
when 100..1000
sizes[:xl] += 1
else
sizes[:xxl] += 1
end
end
puts <<-eol
Commits by number of lines changed by zzak
1-20 : #{sizes[:s]}
20-50 : #{sizes[:m]}
50-100 : #{sizes[:l]}
100-1000 : #{sizes[:xl]}
1000+ : #{sizes[:xxl]}
eol
Commits by number of lines changed by zzak
1-20 : 127
20-50 : 36
50-100 : 16
100-1000 : 34
1000+ : 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment