github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/scripts/git-blame-stats.sh (about)

     1  #!/bin/sh
     2  
     3  # This script produces the list of authors that are "git blame"d for lines in
     4  # .go files under the current directory.
     5  #
     6  # The regular expression for filenames can be overridden on the command line.
     7  # To include all files, use a dot:
     8  #   git-blame-stats.sh .
     9  
    10  FILE_REGEXP='\.go$'
    11  if [ -n "$1" ]; then FILE_REGEXP=$1; fi
    12  
    13  toplevel=$(git rev-parse --show-toplevel)
    14  cp ${toplevel}/scripts/.mailmap ${toplevel}/.mailmap
    15  
    16  git ls-tree -r HEAD \
    17    | cut -f 2 \
    18    | grep -E "$FILE_REGEXP" \
    19    | xargs -n1 git blame --line-porcelain \
    20    | grep "author " \
    21    | sort \
    22    | uniq -c \
    23    | sort -nr
    24  
    25  rm ${toplevel}/.mailmap