This file contains 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
#!/usr/bin/env ruby | |
# Subversion Fame Report | |
# List the user and their number of commits. | |
require 'rubygems' | |
require 'activesupport' | |
log_xml = `svn log -q --xml` | |
svn_logs = XmlSimple.xml_in(log_xml)['logentry'] | |
report_hash = svn_logs.inject({}) do |report,log| | |
author = log['author'][0] | |
report[author] ||= {:commit_count => 0} | |
report[author][:commit_count] += 1 | |
report | |
end | |
commits_authors = report_hash.keys.map { |a| [report_hash[a][:commit_count], a] } | |
commits_authors = commits_authors.sort_by(&:first).reverse | |
cc_colsize = commits_authors.map(&:first).max.to_s.size | |
a_colsize = commits_authors.map(&:last).inject{|m,w| m.length > w.length ? m : w }.size | |
final_report = commits_authors.map do |ca| | |
c,a = ca | |
" #{c.to_s.rjust(cc_colsize)} #{a.ljust(a_colsize)}" | |
end.join("\n") | |
puts final_report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment