Created
July 24, 2012 14:30
-
-
Save tuzz/3170227 to your computer and use it in GitHub Desktop.
Generate a pie chart showing commits by author in a git repository
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
| #!/usr/bin/ruby | |
| # Run in the root directory of a git repository with ruby commits.rb | |
| # Depends upon the 'rmagic' and 'gruff' gems. | |
| require 'rubygems' | |
| require 'gruff' | |
| commits = `git shortlog -ns`.split("\n").map { |e| e.strip.split("\t") }.map { |n, a| [a, n.to_i] } | |
| module Gruff | |
| class Base | |
| def label(value) | |
| label = if @marker_count.to_f == 0 | |
| value.to_i.to_s | |
| elsif ((@spread.to_f % @marker_count.to_f == 0) || | |
| !@y_axis_increment.nil?) | |
| value.to_i.to_s | |
| elsif @spread > 10.0 | |
| sprintf("%0i", value) | |
| elsif @spread >= 3.0 | |
| sprintf("%0.2f", value) | |
| else | |
| value.to_s | |
| end | |
| parts = label.split('.') | |
| parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{THOUSAND_SEPARATOR}") | |
| parts.join('.') | |
| end | |
| end | |
| end | |
| g = Gruff::Pie.new | |
| g.title = "Git commits by author" | |
| commits.each { |a, n| g.data(a, n) } | |
| g.write("commits.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment