Skip to content

Commit 02acb13

Browse files
committed
git-author-stats: added, removed, modified lines of code for an author
1 parent eb5d0a0 commit 02acb13

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

git-author-stats

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
if [[ "$1" == '--num' ]]; then NUMBERS_ONLY=1; shift; fi
4+
5+
author=$1
6+
if [[ -z "$author" ]]; then
7+
echo "Usage: git author-stats [author name]"
8+
exit
9+
fi
10+
11+
git log --author="$author" --pretty=tformat: --numstat | awk '{
12+
added += $1;
13+
removed += $2;
14+
modified += $1 - -$2;
15+
total += $1 - $2;
16+
} END {
17+
if (NUMBERS_ONLY)
18+
printf "Added: %s, removed: %s, total: %s, modified: %s lines\n", added, removed, total, modified
19+
else
20+
printf "%s %s %s %s", added, removed, total, modified
21+
}'

0 commit comments

Comments
 (0)