File: count_contrib.sh

package info (click to toggle)
volk 3.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 4,164 kB
  • sloc: ansic: 50,363; cpp: 2,840; asm: 918; python: 897; xml: 385; sh: 157; makefile: 14
file content (56 lines) | stat: -rwxr-xr-x 1,886 bytes parent folder | download | duplicates (4)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Script to check the list of git submitters against the table of re-submitting
# users from the AUTHORFILE. Requires the authors to be listed in
# | ... | ... | email@address.com |
# format.
#
# We can add another table of "git committers who are exempt from the need to
# relicense due to their contributions being under an acceptable license
# already" if we need; no changes to this script would be necessary.
#
# This script is part of VOLK.
#
# Copyright 2021 Marcus Müller
# SPDX-License-Identifier: MPL-2.0

rootdir=`git rev-parse --show-toplevel`
if [[ "$#" -lt 1 ]]
then
    authorfile=$rootdir/AUTHORS_RESUBMITTING_UNDER_LGPL_LICENSE.md
else
    authorfile=$1
fi
if [[ ! -r $authorfile ]]
then
    echo "$authorfile: file not readable"
    exit -1
fi

allfiles=`git ls-files $rootdir`
lgplers="$(sed -ne 's/^|[^|]*|[^|]*| \([^|]*\)|/\1/ip' $authorfile)"
lgplers="$lgplers 32478819+fritterhoff@users.noreply.github.com douggeiger@users.noreply.github.com"
authorcounts="$(echo "$allfiles" | while read f; do git blame --line-porcelain --ignore-rev 092a59997a1e1d5f421a0a5f87ee655ad173b93f $f 2>/dev/null | sed -ne 's/^author-mail <\([^>]*\)>/\1/p'; done | sort -f | uniq -ic | sort -n)"

total_loc=0
missing_loc=0

while read -r line
do
    authoremail=$(echo "$line" | sed 's/^ *\([[:digit:]]*\) *\([^, ]*\)$/\2/g')
    authorlines=$(echo "$line" | sed 's/^ *\([[:digit:]]*\) *\([^, ]*\)$/\1/g')
    total_loc=$(( $authorlines + $total_loc ))
    if ! ( echo "$lgplers" | grep -i "$authoremail" ) > /dev/null
    then
        echo "missing: \"$authoremail\" (${authorlines} LOC)"
        missingloc=$(($missingloc + $authorlines))
    fi
done < <(echo "$authorcounts")

percentage=$(echo "scale=2; 100.0 * $missingloc/$total_loc" | bc)
echo "Missing $missingloc of $total_loc LOC in total ($percentage%)"

if [[  "$missingloc" -gt 0 ]]
then
   exit -2
fi
exit 0