Tuesday, May 2, 2017

gitstats

A while ago I discovered gitstats which is a cool tool to do some quick analytics on your code base including the lines of code, number of commits by author, types and counts of files, etc.

More than a year later and I lost that tool with the move to a new computer, but I was asked today to see some of those statistics again. Alas, the brew install command I used last time yielded no results (I guess it got moved or something) so I spent some time trying this and that until I was again able to run a report.

These steps are obvious in retrospect, but I don't want to forget them so I'm going to write them down:

  • Create a symbolic link to python2
    • gitstats requires python2, but the latest version of macOS doesn't have it. To further add to some confusion macOS has a System Integrity Protection feature which requires us to make a symbolic link slightly differently.
    • sudo ln -s /usr/bin/python2.6 /usr/local/bin/python2
  • Next install GnuPlot which is a dependency used in gitstats
    • brew install gnuplot
  • Now clone the repo
  • An run it
    • cd gitstats
    • .gitstats ~/Projects/source-repo ~/Projects/source-repo/target/stats
      • i.e. .gitstats [path to repo] [path to output dir]
Hope this helps.