1

I want to track the improvement of a project over time in git.

I need line of code statistics by time. For example.

Time        LOC
-----       -----
01/01/2015 29021
01/08/2015 29987
......

gitstats is throwing some weird error. So I need another alternative.

Any ideas?

emredmrl
  • 103
  • 1
  • 3
  • 9

2 Answers2

1

Here's the start of an idea.

You could have a little script which checks out a ref, and outputs all non-binary code content with:

#!/bin/sh
# catAll.sh
git checkout $1;
for i in `git grep --cached -Il ''`; do
    cat $i
done

Then, pipe that output to wc to get the LOC:

catAll.sh | wc -l

Get the date of a commit with:

git show -s --format=%ci <sha>

Then, (and this could take long time to run depending on the size of your repo) run the command with HEAD, HEAD~, HEAD~~, etc.

This would involve a little scripting to put it all together, but could be wrapped in a nice command to spit out the last, say 5, commit points.

Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115
1

I would suggest https://github.com/AlDanial/cloc .

I used to use it when it was on Sourceforge and found it very useful. If you must let yourself be ruled by metrics. ;-)

Mort
  • 3,379
  • 1
  • 25
  • 40