-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.sh
executable file
·28 lines (19 loc) · 727 Bytes
/
stats.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
#parameters in console
# from = yyyy-mm-dd
# to = yyyy-mm-dd
DETAILLOG=stats.log
from=$1
to=$2
addedLines=0
deletedLines=0
echo ${from} - ${to} >> $DETAILLOG
for i in `git log --after="${from} 00:00" --before="${to} 00:00" --pretty=format:"%H"`; do
commitString=${i}"^!"
values=($(git log --numstat --pretty=\"%H\" ${commitString} | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("%d,%d\n", plus, minus)}'))
IFS=', ' read -r -a valuesArray <<< "$values"
addedLines=$((addedLines + ${valuesArray[0]}))
deletedLines=$((deletedLines + ${valuesArray[1]}))
echo "commit: " ${i} " : " ${valuesArray[0]} " " ${valuesArray[1]} >> $DETAILLOG
done;
echo ${addedLines}","${deletedLines}