Follow Skinkers.




Generate visual Stats / Graphs from a Git repository (on OSX)

  February 13th, 2012 | git | Matt Bryson

I was looking to get some slightly more detailed stats out of a git repo, more than just the command line stats you can generate. There are a couple of tools out there that generate graphs and charts for you, but they rely heavily on external libraries.

The best looking one was GitStats http://gitstats.sourceforge.net/ (example). But after checking off the pre reqs of Python, X11 and downloading and compiling GnuPlot it still wasn’t creating PNG graphs due to missing 3rd party libraries!! It was proving to be a bit of a pain, but I finally managed to get it all working with just 2 downloads (I already had python) – GitStats and a pre compiled binary of GnuPlot that contains all the 3rd party dependencies used by GitStat.

Below are some simple steps to get it up and running on OSX:

Pre Requisites
Clone GitStats, I placed it into my developer folder:

$ cd ~/developer
$ git clone git://repo.or.cz/gitstats.git

Download and Install Python: http://www.python.org/download/releases/
Download and run a GNUPlot .dmg and copy the app to Applications: http://www.miscdebris.net/upload/gnuplot-4.2.5-i386.dmg

Add the GNUPlot binary to your $PATH, I added it to my .profile settings, in terminal run:

$ echo 'export PATH=/Applications/Gnuplot.app/Contents/Resources/bin:$PATH:$PATH' >> ~/.profile

Re boot terminal to load the new path settings.

Now navigate to your GitStats directory, and run the following, where “~/workspace/project” is the path to your git repo, and “~/public_html/project” is the output dir to save the HTML charts.

$ ./gitstats ~/workspace/project ~/public_html/project

And now run the index.html in your ~/public_html/project directory.

You can now share some lovely charts and graphs with your project managers :)

Tags: , , ,

Leave a Reply