Skip to content

Commit ece251b

Browse files
committed
Script to count contributors and commits per development cycle
1 parent c068d5b commit ece251b

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

count-contributors.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/sh
2+
3+
LC_ALL=C LANG=C
4+
export LC_ALL LANG
5+
6+
fmt="%-10s | %7d %7d %7d | %7d %7d | %-10s\n"
7+
hfmt=$(printf "%s" "$fmt" | sed -e 's/d/s/g')
8+
head=$(printf "$hfmt" release new this total this total date)
9+
10+
old= ocommitcnt=
11+
git for-each-ref --format='%(refname:short)' refs/tags/ |
12+
perl -w -e '
13+
use strict;
14+
my @version = ();
15+
my %asked = map { $_ => $_ } @ARGV;
16+
17+
while (<STDIN>) {
18+
next unless (/^(v(\d+)\.(\d+)(?:\.(\d+))?(?:-rc(\d+))?)$/);
19+
# $1 = tag == v$2.$3(.$4)?(-rc$5)?
20+
21+
if (exists $asked{$1}) {
22+
; # ok
23+
} elsif (defined $5) {
24+
# skip -rc releases
25+
next;
26+
} elsif ($2 == 0) {
27+
# not worth showing breakdown during v0.99 period
28+
next unless ($1 eq "v0.99");
29+
} elsif ($2 == 1) {
30+
# not worth showing breakdown before v1.4.0
31+
next if ($3 < 4 && $4);
32+
}
33+
push @version, [$1, $2, $3, $4, $5];
34+
}
35+
for (sort { (
36+
$a->[1] <=> $b->[1] ||
37+
$a->[2] <=> $b->[2] ||
38+
$a->[3] <=> $b->[3] ||
39+
( (defined $a->[4] && defined $b->[4])
40+
? $a->[4] <=> $b->[4]
41+
: defined $a->[4]
42+
? -1 : 1 ) ); } @version) {
43+
print $_->[0], "\n";
44+
}
45+
' "$@" |
46+
while read new
47+
do
48+
commitcnt=$(git rev-list --no-merges "$new" | wc -l)
49+
git shortlog -s -n "$new" |
50+
sed -e 's/^[ 0-9]*//' |
51+
sort >/var/tmp/new
52+
if test -n "$old"
53+
then
54+
comm -13 /var/tmp/old /var/tmp/new >"/var/tmp/cont-$new"
55+
i=$(git shortlog -s -n "$old..$new" |
56+
sed -e 's/^[ 0-9]*//' |
57+
wc -l)
58+
cc=$(( $commitcnt - $ocommitcnt ))
59+
else
60+
i=$(wc -l </var/tmp/new)
61+
cat /var/tmp/new >"/var/tmp/cont-$new"
62+
cc=$(( $commitcnt + 0 ))
63+
fi
64+
old=$new
65+
mv /var/tmp/new /var/tmp/old
66+
n=$(wc -l <"/var/tmp/cont-$new")
67+
c=$(wc -l <"/var/tmp/old")
68+
t=$(git show -s --format="%ci" "$old^0" | sed -e "s/ .*//")
69+
ocommitcnt=$commitcnt
70+
test -z "$head" || echo "$head"
71+
printf "$fmt" $new $n $i $c $cc $commitcnt $t
72+
head=
73+
done

0 commit comments

Comments
 (0)