Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine current code distribution by author

Tags:

git

I thought it would be neat if it were possible to take a Git repository, run some script, and have it generate the number of lines in the code base, and the proportion of each author that contributed to it.

Basically, because I am kind of a competitive coder, I would like a personal metric to see if the number of lines that I've written (in the current HEAD) are greater than my partner(s). It would be a fun statistic to say "I wrote % of the current codebase".

Has anyone ever thought to do this? I've looked for a way, but my shell scripting is not the best, so I couldn't do it alone.

like image 908
Sean Freitag Avatar asked Apr 20 '12 03:04

Sean Freitag


2 Answers

You can use git log, as illustrated in "Which Git commit stats are easy to pull".

Or you can have a look at Git Lookatgit project, which does inspect the number of lines changed, as seen in its gitauthor.rb class.

like image 87
VonC Avatar answered Oct 04 '22 05:10

VonC


You probably need gitdm, it can do exactly what you need. We use it for Mahara project to produce contribution statistics.

Just do what README suggests:

A typical command line used to generate the "who write 2.6.x" LWN articles looks like:

git log -p -M v2.6.19..v2.6.20 |  gitdm -u -s -a -o results -h results.html

You can also customise it for your own purposes.

like image 37
Ruslan Kabalin Avatar answered Oct 04 '22 05:10

Ruslan Kabalin