Show number of changed lines per author in git

后端 未结 6 938
灰色年华
灰色年华 2020-12-13 02:48

i want to see the number of removed/added line, grouped by author for a given branch in git history. there is git shortlog -s which shows me the number of commi

6条回答
  •  余生分开走
    2020-12-13 03:01

    This script here will do it. Put it into authorship.sh, chmod +x it, and you're all set.

    #!/bin/sh
    declare -A map
    while read line; do
        if grep "^[a-zA-Z]" <<< "$line" > /dev/null; then
            current="$line"
            if [ -z "${map[$current]}" ]; then 
                map[$current]=0
            fi
        elif grep "^[0-9]" <<<"$line" >/dev/null; then
            for i in $(cut -f 1,2 <<< "$line"); do
                map[$current]=$((map[$current] + $i))
            done
        fi
    done <<< "$(git log --numstat --pretty="%aN")"
    
    for i in "${!map[@]}"; do
        echo -e "$i:${map[$i]}"
    done | sort -nr -t ":" -k 2 | column -t -s ":"
    

提交回复
热议问题