4 # Copyright (c) 2009-2020 The CVC4 Project
6 # usage: get-authors [ files... ]
8 # This script uses git blame -w -N -C to get the original author
11 gituser
="`git config user.name` <`git config user.email`>"
13 while [ $# -gt 0 ]; do
16 if ! grep -q " Top contributors" "$f"
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;
27 total_lines
=$
(wc -l "$f" |
awk '{print$1}')
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.
33 # Each line looks a follows:
35 # sha1 filename (Author Name 2019-03-25 13:36:07 -0800 42) code ...
37 git blame
-w -M -C -L $header_lines,$total_lines "$f" | \
39 # Discard everthing left to first '('
40 awk -F '(' '{print $2}' | \
42 # Discard the source code left to first ')' and omit lines that begin
46 # (3) } ... namespace ...
50 '$2 !~ /^[ \t]*(#include|namespace|}.*namespace.*|[ \t]*$)/ {print $1}' | \
52 # Keep author names only, remove the last 4 columns in ( ... )
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/' | \
75 # Determine top three contributors
76 sort |
uniq -c |
sort -rn |
head -n3 | \
78 # Remove first columns from uniq -c (number of lines)
79 awk '{$1=""; print}' | \
81 # Comma separated list of author names, remove leading whitespaces, and
82 # remove trailing comma
83 tr '\n' ', ' |
sed 's/^[ \t]*//' |
sed 's/,$/\n/'