#!/bin/sh --
# $Id$
#
# Script to tell $1 about PRs in state $2
#
PATH=${PATH}:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin; export PATH
MAIL=/usr/bin/mail
QUERY_PR="/usr/local/bin/query-pr"

usage() {
	echo Usage: `basename $0` responsible state > /dev/stderr
}

if [ ${#} -ne 2 ]; then
	usage
	exit 1
fi

WHO=$1
STATE=$2

PRS=`${QUERY_PR} -q -s ${STATE} -r ${WHO} 2>/dev/null`

if [ -z "${PRS}" ]; then
	exit 0
fi

${MAIL} -s "PRs in state ${STATE} assigned to ports-committers" -b bugmeister ${WHO} << EOM

The following PRs in the ${STATE} state require attention.

${PRS}

Thank you,

The Automated Repocopy Nagger
(/c/gnats/tool/repocopy/).

EOM
