利用awk语言,代码统计,包含了使用框架自带的代码量
- xxx代码量统计
git log --author="xxx" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'
- 项目总代码量统计
git log --author="" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'
- 每个人的统计
git log --format='%aN' | sort -u | while read name; do echo -en "$name"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf " added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done