Last active
February 6, 2019 14:09
-
-
Save unacceptable/a06a72a18a8ae77966de569aea860cc9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| AUTHOR="Robert J." | |
| GIT_DIR="$HOME/Git" | |
| print(){ | |
| var="$1"; | |
| size="${#var}"; | |
| printf -v sep "%${size}s" "-"; | |
| printf "\n%s\n%s\n" "$var" "${sep// /-}" | |
| } | |
| while read -r REPO; do | |
| print "${REPO%%.git*}" | |
| cd "${REPO%%.git*}" || exit | |
| COMMITS="$(git log --author="$AUTHOR" --after="1 year ago" --name-status --oneline 2> /dev/null || true)" | |
| printf "commits - %s\n" "$(echo "$COMMITS" | grep -vc '^M' | xargs echo)" | |
| printf "merges - %s\n" "$(echo "$COMMITS" | grep -c '^M' | xargs echo)" | |
| cd "$GIT_DIR" || exit | |
| done < <( | |
| cd "$GIT_DIR" && find . -name '.git' -type d | |
| ) > review.report | |
| awk -F ' - ' '/commits/ {sum += $2} END {print "total commits: " sum}' review.report | |
| awk -F ' - ' '/merges/ {sum += $2} END {print "total merges: " sum}' review.report | |
| awk -F ' - ' '{sum += $2} END {print "total git contributions: " sum}' review.report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment