#!/bin/bash

set -e
set -u

if [ -z "$1" ]; then
  echo "Usage: $0 from..to"
fi

RANGE="$1"

# TODO: check if commits from bob.ham@puri.sm and martin are found
WHO="@puri.sm angus@akkea.ca agx@sigxcpu.org martink@posteo.de"
URL="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id="

function commits()
{
  for w in $WHO; do
    git -P log --format="[%s]($URL%H)" --author="${w}" "${RANGE}"
  done
}

function reviews_and_tested()
{
  for w in $WHO; do
    git -P log --pretty=oneline -E --grep "(Reviewed|Tested)-by: .*$w" "${RANGE}"
  done
}

echo "Contributions"
echo "-------------"
commits
echo

echo "*-by's"
echo "------"
reviews_and_tested | wc -l
echo
