installed_progs.t: Python checks stdout too, 150 ok
[sunny256-utils.git] / git-authoract
blob174417c82633e95dd0f6677d315b0e8f4770093a
1 #!/usr/bin/env bash
3 #=======================================================================
4 # git-authoract
5 # File ID: 6d9eb5a8-2526-11e4-be0d-c80aa9e67bbd
6 # [Description]
7 # License: GNU General Public License version 2 or later.
8 #=======================================================================
10 outfile=/tmp/git-authors.txt
12 git log --format="%ci %aN" "$@" | \
13 cut -c 1-7,26- | \
14 sort | \
15 uniq | \
16 cut -c -7 | \
17 uniq -c | \
18 rmspcall | \
19 perl -pe 's/^(\d+)\s(\S+)/$2 $1/' >$outfile
21 firstyear=$(head -1 $outfile | cut -f 1 -d -)
22 curryear=$(date +%Y)
23 for y in $(seq $firstyear $curryear); do
24 for m in $(seq -w 1 12); do
25 grep -q ^$y-$m $outfile || echo $y-$m 0 >>$outfile
26 done
27 done
28 sort $outfile >${outfile}.tmp
29 mv ${outfile}.tmp $outfile
31 headzero="$(cut -f 2 -d ' ' $outfile | uniq -c | rmspcall | head -1 | grep ' 0$')"
32 if test -n "$headzero"; then
33 numhead=$(echo $headzero | cut -f 1 -d ' ')
34 linecount=$(wc -l <$outfile)
35 tail -n -$[$linecount - $numhead] $outfile >${outfile}.tmp
36 mv ${outfile}.tmp $outfile
39 tailzero="$(cut -f 2 -d ' ' $outfile | uniq -c | rmspcall | tail -1 | grep ' 0$')"
40 if test -n "$tailzero"; then
41 numtail=$(echo $tailzero | cut -f 1 -d ' ')
42 linecount=$(wc -l <$outfile)
43 head -n $[$linecount - $numtail] $outfile >${outfile}.tmp
44 mv ${outfile}.tmp $outfile
47 stpl -f %Y-%m $outfile