tj.git-extras/bin/git-authors
2015-02-07 17:24:21 +01:00

36 lines
521 B
Bash
Executable file

#!/usr/bin/env bash
LIST=false
FILE=""
if test "$1" = "-l" || test "$1" = "--list"; then
LIST=true
else
FILE=$1
if test "$FILE" = ""; then
FILE=`ls | egrep 'authors|contributors' -i|head -n1`
if test "$FILE" = ""; then
FILE='AUTHORS'
fi
fi
fi
#
# list authors sorted by number of commits (descending).
#
authors() {
git shortlog -sne | awk '{$1=""; sub(" ", ""); print}'
}
#
# authors.
#
if $LIST; then
echo "$(authors)"
else
authors >> $FILE
test -n "$EDITOR" && $EDITOR $FILE
fi