Eliminate equality query dependence on quantifiers engine (#5831)
[cvc5.git] / contrib / get-authors
1 #!/bin/sh
2 #
3 # get-authors
4 # Copyright (c) 2009-2020 The CVC4 Project
5 #
6 # usage: get-authors [ files... ]
7 #
8 # This script uses git blame -w -N -C to get the original author
9 #
10
11 gituser="`git config user.name` <`git config user.email`>"
12
13 while [ $# -gt 0 ]; do
14 f=$1
15 shift
16 if ! grep -q " Top contributors" "$f"
17 then
18 header_lines=0
19 else
20 header_lines=$(grep "\*\*\/" "$f" -m 1 -n | cut -d ':' -f 1)
21 if [ -z $header_lines ]; then
22 header_lines=$(grep "^##$" "$f" -m 3 -n | tail -n 1 | cut -d ':' -f 1)
23 [ -z "$header_lines" ] && header_lines=0;
24 fi
25 fi
26 ((header_lines++))
27 total_lines=$(wc -l "$f" | awk '{print$1}')
28
29 # Note: Instead of using the porcelain format, we extract the author name
30 # information from the humand readable format since it prints the source code
31 # and we want to exclude specific lines of code.
32
33 # Each line looks a follows:
34 #
35 # sha1 filename (Author Name 2019-03-25 13:36:07 -0800 42) code ...
36
37 git blame -w -M -C -L $header_lines,$total_lines "$f" | \
38
39 # Discard everthing left to first '('
40 awk -F '(' '{print $2}' | \
41
42 # Discard the source code left to first ')' and omit lines that begin
43 # with:
44 # (1) #include
45 # (2) namespace
46 # (3) } ... namespace ...
47 # (4) empty lines
48 #
49 awk -F ')' \
50 '$2 !~ /^[ \t]*(#include|namespace|}.*namespace.*|[ \t]*$)/ {print $1}' | \
51
52 # Keep author names only, remove the last 4 columns in ( ... )
53
54 awk 'NF{NF-=4};1' | \
55
56 # Fix author names
57 sed "s,Not Committed Yet <not.committed.yet>,$gituser," | \
58 sed 's/PaulMeng/Paul Meng/' | \
59 sed 's/barrettcw/Clark Barrett/' | \
60 sed 's/Andres Nötzli/Andres Noetzli/' | \
61 sed 's/Andres Notzli/Andres Noetzli/' | \
62 sed 's/guykatzz/Guy/' | \
63 sed 's/Guy Katz/Guy/' | \
64 sed 's/Guy/Guy Katz/' | \
65 sed 's/makaimann/Makai Mann/' | \
66 sed 's/Martin Brain/Martin/' | \
67 sed 's/Martin/Martin Brain/' | \
68 sed 's/nafur/Gereon Kremer/' | \
69 sed 's/justinxu421/Justin Xu/' | \
70 sed 's/yoni206/Yoni Zohar/' | \
71 sed 's/ayveejay/Andrew V. Jones/' | \
72 sed 's/FabianWolff/Fabian Wolff/' | \
73 sed 's/mudathirmahgoub/Mudathir Mohamed/' | \
74
75 # Determine top three contributors
76 sort | uniq -c | sort -rn | head -n3 | \
77
78 # Remove first columns from uniq -c (number of lines)
79 awk '{$1=""; print}' | \
80
81 # Comma separated list of author names, remove leading whitespaces, and
82 # remove trailing comma
83 tr '\n' ', ' | sed 's/^[ \t]*//' | sed 's/,$/\n/'
84 done