[git] git log stats 보기
ITWeb/개발일반 2018. 1. 12. 15:45그냥 제가 보고 싶은 형태로 구성하기 위해 스크립트 만들어 봤습니다.
참고문서)
https://git-scm.com/docs/git-log
https://git-scm.com/docs/pretty-formats
#!/usr/bin/env bash
DAYS_AGO=$1
DATE=`date -v -"$DAYS_AGO"d +%F`
PWD=`pwd`
echo "Date : $DATE" > "git-stats-$DATE.log"
# This script must exist under git repository.
echo "[Commit Statistics]" >> "git-stats-$DATE.log"
# total commit stats
USER_COUNT=`git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --format='%aN %ce' | sort -u | wc -l`
echo "Total Commit Users : $USER_COUNT" >> "git-stats-$DATE.log"
git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "git-stats-$DATE.log"
echo "" >> "git-stats-$DATE.log"
echo "[Committers]" >> "git-stats-$DATE.log"
# commit user list
git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --format='%aN %ce' | sort -u >> "git-stats-$DATE.log"
echo "" >> "git-stats-$DATE.log"
echo "[Commit Logs]" >> "git-stats-$DATE.log"
# each user commit stats
git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "git-stats-$DATE.log"