#!/bin/sh

# Arguments.
REPOS="$1"
TXN="$2"

# Programs.
SVNLOOK=/opt/local/bin/svnlook
SED=/usr/bin/sed
GREP=/usr/bin/grep

# Make sure names of new tags conform to requirements.
TAGS=`$SVNLOOK changed -t "$TXN" "$REPOS" | $SED -E -n 's%^A   (.+/)?tags/%%p' | $SED -E 's%/.*$%%'`
for TAG in $TAGS; do
	echo $TAG | $GREP -E '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+[RTA]$' > /dev/null
	if [ $? -ne 0 ]; then
		echo "Tag \"$TAG\" does not conform to naming conventions." 1>&2
		echo "Please name tags using the form #.#.#(R|T|A), e.g. 1.2.3A" 1>&2
		exit 1
	fi
done

# All checks passed, so allow the commit.
exit 0


