1 | #!/bin/bash |
---|
2 | # |
---|
3 | # Apologies for all this nastiness. This script could be so much cleaner... |
---|
4 | |
---|
5 | COMMITS="/tmp/commits.txt" |
---|
6 | LOGMSG="/tmp/logmsg.txt" |
---|
7 | ACKS="/tmp/acks.txt" |
---|
8 | ACKERS="/tmp/ackers.txt" |
---|
9 | |
---|
10 | # Required to read one line at a time, instead of one word at a time |
---|
11 | SAVEIFS=$IFS |
---|
12 | IFS=$(echo -en "\n\b") |
---|
13 | |
---|
14 | echo "Generic statistics:" |
---|
15 | echo |
---|
16 | |
---|
17 | # Generate a list of commit IDs, unless told otherwise |
---|
18 | if ! [ "$1" == "--no-log-parsing" ]; then |
---|
19 | |
---|
20 | # Clean up after previous runs |
---|
21 | rm -f $COMMITS $LOGMSG $ACKS $ACKERS |
---|
22 | |
---|
23 | git log --since="2 years ago"|grep "^commit"|cut -d " " -f 2 > $COMMITS |
---|
24 | |
---|
25 | # Internal helper variables |
---|
26 | COMMITCOUNT=0 |
---|
27 | ACKCOUNT=0 |
---|
28 | |
---|
29 | for COMMIT in `cat $COMMITS`; do |
---|
30 | |
---|
31 | # Produces commit outputs like this: |
---|
32 | # |
---|
33 | # build: autoconf: misc sockets fixups+ |
---|
34 | # Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com> |
---|
35 | # Acked-by: David Sommerseth <davids@redhat.com> |
---|
36 | # Signed-off-by: David Sommerseth <davids@redhat.com> |
---|
37 | |
---|
38 | # The -s switch removes the diff from git-show output, although |
---|
39 | # it's undocumented. |
---|
40 | COMMITNAME=`git show -s --pretty=format:"%s" $COMMIT` |
---|
41 | ACKERNUM=`git show -s --pretty=format:"%b" $COMMIT|grep "Acked-by"|wc --lines` |
---|
42 | ACKCOUNT=$(( $ACKCOUNT + $ACKERNUM )) |
---|
43 | |
---|
44 | # Isolate individual ACK lines |
---|
45 | git show -s --pretty=format:"%b $COMMIT"|grep "Acked-by" >> $ACKS |
---|
46 | |
---|
47 | COMMITCOUNT=$(( $COMMITCOUNT + 1 )) |
---|
48 | |
---|
49 | done |
---|
50 | |
---|
51 | echo "Commit count: "$COMMITCOUNT |
---|
52 | echo "ACK number: "$ACKCOUNT |
---|
53 | |
---|
54 | # Calculate average ACK count per patch. |
---|
55 | AVGACKCOUNT=`echo "scale=2;$ACKCOUNT/$COMMITCOUNT"|bc` |
---|
56 | echo "Average ACK count: $AVGACKCOUNT" |
---|
57 | fi |
---|
58 | |
---|
59 | echo |
---|
60 | echo "ACKs by person:" |
---|
61 | echo |
---|
62 | |
---|
63 | # Check the ACK statistics by person |
---|
64 | for ACKER in `git log --since="2 years ago" --pretty=format:"%b"|grep "Acked-by"|sort|uniq|cut -d ":" -f 2|cut -d "<" -f 1|sed s/"^ "//1`; do |
---|
65 | echo -n $ACKER |
---|
66 | echo `git log --since="2 years ago" --pretty=format:"%b"|grep "Acked-by: $ACKER"|wc --lines` |
---|
67 | done |
---|