Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created February 1, 2009 19:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save metaskills/55952 to your computer and use it in GitHub Desktop.
#!/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