Git: How to estimate a contribution of a person to my project in terms of added/changed lines of code?

后端 未结 8 1631
醉梦人生
醉梦人生 2020-12-04 07:42

I have a GIT repository and I want to calculate how many lines of code were added/changed by one person or a group of persons during some period of time. Is it possible to c

相关标签:
8条回答
  • 2020-12-04 08:35

    You can generate stats using Gitstats. It has an 'Authors' section which includes number of lines add/removed by the top 20 authors (top 20 by commit count).

    Edit: There's also Git: Blame Statistics

    0 讨论(0)
  • 2020-12-04 08:36

    I'm not sure the line of code would be a good metric but if you are looking for just total commits and compare it against other engineers then you could use this: no plugin or addon is needed...just pure shell script, it was tested in zshell

    Note: you must run this from the repo folder

    #!/bin/env zsh
    team_total=$(git shortlog -s -n |sed 's/\t/,/g'|cut -f1 -d, |bc -l|awk '{sum+=$1}END{print sum}');
    tmp_counter='/tmp/counter.txt';
    tmp_user='/tmp/users.txt';
    tmp_percentage='/tmp/counters_users'
    # if you are running this again it make the file empty or you can rm it 
    rm $tmp_percentage $tmp_user $tmp_counter
    git shortlog -s -n |sed 's/\t/,/g'|cut -f2 -d, >>$tmp_user;
    git shortlog -s -n |sed 's/\t/,/g'|cut -f1 -d, >>$tmp_counter;
    
    cat $tmp_counter | while read LINE; do
        printf '%.2f %%  \n' $(echo \($LINE/$team_total\)\*100 |bc -l ) >>$tmp_percentage
    done
    echo 'commits %      | contributor     | # of commits';paste  $tmp_percentage $tmp_user $tmp_counter
    

    here is the sample report:

    0 讨论(0)
提交回复
热议问题