Last active
August 11, 2019 22:37
-
-
Save BR0kEN-/33872aabf8c2f83ec4d4 to your computer and use it in GitHub Desktop.
Per-user repository statistic (commits, additions and deletions counter)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
BRANCH="$1" | |
IFS="|" | |
# Show help. | |
if [ "help" == "$BRANCH" ]; then | |
echo "$0 BRANCH" | |
exit 0 | |
fi | |
: "${BRANCH:="master"}" | |
# Ensure that we're inside of directory with initialized Git repository. | |
git status > /dev/null | |
# Check local branch existence. | |
git rev-parse --verify "$BRANCH" > /dev/null | |
echo "Statistics for \"$BRANCH\":" | |
for DATA in $(git shortlog -sn --no-merges "$BRANCH" | awk 'BEGIN {FS = "\t"}; {print $1 "+" $2 "|"}'); do | |
DATA=$(echo "$DATA" | xargs) | |
COMMITS="${DATA%+*}" | |
USERNAME="${DATA#*+}" | |
echo "------------------------------------------------------------------" | |
echo "$USERNAME ($COMMITS commits)" | |
git log --author="$USERNAME" --shortstat | awk '/^ [0-9]/ {f += $1; i += $4; d += $6} \ | |
END {printf("%d files changed, %d insertions(+), %d deletions(-)", f, i, d)}' | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment