What's cooking (2021/06 #06)
[git] / Summary
1 #!/bin/sh
2
3 tmp=.git/summary-$$
4 trap 'rm -f $tmp-*' 0
5
6 since="$1"
7 until="$2"
8
9 case 0 in
10 1)
11         bottom=$(git rev-parse master@{"$1"})
12         top=$(git rev-parse master@{"$2"})
13         ;;
14 0)
15         git rev-list --first-parent --since="$since" --until="$until" \
16                 master >"$tmp-1" &&
17         bottom=$(tail -n 1 "$tmp-1") &&
18         top=$(head -n 1 "$tmp-1") &&
19         rm -f "$tmp-1"
20         ;;
21 esac
22
23 num_patches=$(git rev-list --no-merges $bottom..$top | wc -l)
24 git shortlog -s -n --no-merges $bottom..$top >"$tmp-0.txt"
25 num_contrib=$(wc -l <"$tmp-0.txt")
26
27 summary=$(git diff --stat -M $bottom..$top | tail -n 1)
28 num_files=$(expr "$summary" : ' *\([1-9][0-9]*\) files changed')
29 num_added=$(expr "$summary" : '.*changed, \([1-9][0-9]*\) insertions')
30 num_deleted=$(expr "$summary" : '.*, \([1-9][0-9]*\) deletions')
31
32 cat <<EOF
33 During the period of $since .. $until:
34
35         Number of contributors  : $num_contrib
36         Number of change sets   : $num_patches
37         Number of changed files : $num_files
38         Number of added lines   : $num_added
39         Number of deleted lines : $num_deleted
40
41 Changes during this period are as follows:
42
43 EOF
44
45 git shortlog -w72,2,4 --no-merges $bottom..$top
46
47 git diff --dirstat $bottom..$top