Created
January 26, 2012 15:55
-
-
Save aslakhellesoy/1683443 to your computer and use it in GitHub Desktop.
Small script to gather some stats about a project's volatility between releases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def info(prev_tag, tag) | |
`git checkout -q #{tag}` | |
diffstat = `git diff --stat #{prev_tag} #{tag} ./lib`.split(/\n/)[-1] | |
insertions = /(\d+) insertions/.match(diffstat)[1].to_i rescue 0 | |
deletions = /(\d+) deletions/.match(diffstat)[1].to_i rescue 0 | |
sloc = /ruby=(\d+)/m.match(`sloccount lib`)[1].to_i | |
changes = insertions+deletions | |
changetrate = changes.to_f/sloc | |
{ | |
:tag => tag, | |
:insertions => insertions, | |
:deletions => deletions, | |
:sloc => sloc, | |
:changetrate => changetrate | |
} | |
end | |
puts "TAG\tCHANGE RATE %\tSLOC\tINSERTIONS\tDELETIONS" | |
tags = `git tag | sort --version-sort`.split(/\n/) | |
prev_tag = tags[0] | |
tags[1..-1].each do |tag| | |
info = info(prev_tag, tag) | |
puts sprintf("%s\t%f\t%d\t%d\t%d", info[:tag], info[:changetrate]*100, info[:sloc], info[:insertions], info[:deletions]) | |
prev_tag = tag | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment