tj.git-extras/bin/git-authors
Damian Krzeminski a86d850688 use standard git editor in git-authors & git-changelog
The editor used will be chosen from the GIT_EDITOR environment variable,
the core.editor configuration variable, the VISUAL environment variable,
or the EDITOR environment variable (in that order).

That ensures that `git-changelog` and `git-authors` will use the same editor
as `git-commit`, `git-merge` etc.
2015-02-13 17:51:22 -05:00

37 lines
550 B
Bash
Executable file

#!/usr/bin/env bash
LIST=false
FILE=""
EDITOR=$(git var GIT_EDITOR)
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