Git script to measure contributor LOCs

  • and for mercurial

    http://mercurial.selenic.com/wiki/ChurnExtension

    user LOC

        $ hg churn -t users@email 
        30454 ****************************************************
    
    users' changesets

        $ hg churn -c 
        user1     65 ****************************************************
        user2     41 *********************************
        user3     2 **

  • For those of us not on BSD:

        git ls-files -z | xargs -0 -n1 -E'\n' git blame --date short -wCMcp | perl -pe 's/^.*?\((.*?) +\d{4}-\d{2}-\d{2} +\d+\).*/\1/' | sort | uniq -c | sort -rn

  • Is LOC still a worthwhile metric to estimate developer productivity?

  • git blame -p is going to be easier to parse

    example:

        git blame --line-porcelain |awk 'BEGIN { ORS=" " } $1=="author" {for (i=2;i<=NF;++i) print $i; printf("\n")}'|sort|uniq -c|sort -n
    
    better:

        git ls-files -z|xargs -0 -n1 git blame --line-porcelain|awk '$1=="author" {auth=$2; for(i=3;i<=NF;++i) auth=auth " "$i; counts[auth]+=1} END {for(a in counts) print counts[a],a}'

  • Much more extensive and detailed information is provided by https://github.com/hoxu/gitstats

  • Very cool -- thanks for sharing.