summaryrefslogtreecommitdiff
path: root/contrib/get-authors
blob: c0f49fac9f7b00cacfb2999adb71b72106bb6ed9 (plain)
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
#!/bin/sh
#
# get-authors
# Morgan Deters <mdeters@cs.nyu.edu> for CVC4
# Copyright (c) 2009-2014  The CVC4 Project
#
# usage: get-authors [ files... ]
#
# This script uses git to get the original author
#

gituser="`git config user.name` <`git config user.email`>"

if [ "$1" = "--email" ]; then
  strip_email=cat
  shift
else
  strip_email="sed 's, *<[^>]*@[^>]*>,,g'"
fi

while [ $# -gt 0 ]; do
  f=$1
  shift
  contributors=
  if [ -z "`grep " \*\* Top contributors" $f`" ]
  then
    header_lines=0
  else
    header_lines=`grep "\*\*\/" $f -m 1 -n | cut -d ':' -f 1`
    if [ -z $header_lines ]; then header_lines=0; fi
  fi
  ((header_lines++))
  total_lines=`wc -l "$f" | awk '{print$1}'`
  git blame --incremental -L $header_lines,$total_lines "$f" | \
    gawk '/^[0-9a-f]+ [0-9]+ [0-9]+ [0-9]+$/ {nl=$4;} /^summary .*copyright/ {nl=0} /^author / {$1=""; author=$0;} /^author-mail / {mail=$2} /^filename / {while(nl--) {print author,mail}}' | \
    sed "s,Not Committed Yet <not.committed.yet>,$gituser," | \
    sed 's/PaulMeng/Paul Meng/' | \
    sed 's/barrettcw/Clark Barrett/' | \
    sed 's/Andres Nötzli/Andres Noetzli/' | \
    sed 's/Andres Notzli/Andres Noetzli/' | \
    sed 's/guykatzz/Guy/' | \
    sed 's/Guy Katz/Guy/' | \
    sed 's/Guy/Guy Katz/' | \
    eval "$strip_email" | \
    sort | uniq -c | sort -nr | head -n 3 | \
    ( while read lines author; do
        contributors="${contributors:+$contributors, }$author"
      done; \
      echo "$contributors")
done
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback