#!/bin/bash
#
# Gforge wrapper for CVSSpam (loginfo)
# Usage: call from CVSROOT/loginfo as
#   DEFAULT /path/to/cvsspam-wrapper %{sVv}
#


function usage() {
   echo "Usage: $0 <cvsspam_args>"
   echo "   Use %{sVv} for the args"
   exit 0
}

# We need at least one argument
if [ -z "$1" ]; then
   usage
fi

if [ -z "$CVSROOT" ]; then
   "Error: CVSROOT is not defined. Please launch from CVSROOT/loginfo"
   usage
fi

COLLECTDIFFS="/usr/lib/cvsspam/collect_diffs.rb"
FROM="noreply@gforge.example.org"
PROJECT="${CVSROOT##/cvsroot/}"
TO="${PROJECT}-commits@lists.gforge.example.org"

export CVSROOT
${COLLECTDIFFS} --from "$FROM" --to "$TO" $@

