#!/bin/sh # # get-authors # Morgan Deters for CVC4 # Copyright (c) 2009-2013 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 original_author= major_contributors= minor_contributors= total_lines=`wc -l "$f" | awk '{print$1}'` original_author=`git log --use-mailmap --pretty="format:%aN <%aE>" "$f" | tail -1` git blame --incremental "$f" | gawk '/^[0-9a-f]+ [0-9]+ [0-9]+ [0-9]+$/ {nl=$4;} /^author / {$1=""; author=$0;} /^author-mail / {mail=$2} /^filename / {while(nl--) {print author,mail}}' | sed "s,Not Committed Yet ,$gituser," | sort | uniq -c | sort -n | ( while read lines author; do pct=$((100*$lines/$total_lines)) if [ "$author" != "$original_author" ]; then if [ $pct -ge 10 ]; then major_contributors="${major_contributors:+$major_contributors, }$author" else minor_contributors="${minor_contributors:+$minor_contributors, }$author" fi fi done; \ echo "$original_author" echo "${major_contributors:-none}" echo "${minor_contributors:-none}" ) | eval "$strip_email" done