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

后端 未结 8 1742
醉梦人生
醉梦人生 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:21

    you can do that:

    1) Run:

    nano contribution.sh
    

    2) fill :

    if [ $# -eq 1 ]
    then
            git log --author=$1 --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' - > logs.txt
            cat logs.txt
    else
            echo "ERROR: you should pass username at argument"
    fi
    

    3) Run :

    chmod +x contribution.sh
    

    4) Now you can see your contribution with:

    ./contribution.sh your_git_username
    

提交回复
热议问题