[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Post commit script for losers who steal even revisions

From: Ryan Schmidt <subversion-2006c_at_ryandesign.com>
Date: 2006-08-25 01:15:24 CEST

On Aug 24, 2006, at 23:16, Young, Jason (GE Indust, GE Fanuc) wrote:

> We have a user here that watches the revision numbers, and when it's
> 1000, 2000, 3000, etc, he'll just change one character in the file,
> and
> then check it in. Does anyone have a post-commit script for Windows
> that can check if the revision is divisible by 1000 and checked in
> by a
> certain person? I want those commits to fail, so that he can no
> longer
> steal the glory.

Ha! Brilliant. :-)

Here's a pre-commit hook for Unix/Linux/Mac OS X. (Sorry; I'm not up
on Windows programming, but it should be easy enough to convert this
to Perl or a batch file.)

Note that the revision number isn't assigned until after the pre-
commit hook ends. So it's possible that a banned author could still
commit the banned revision if someone else is committing something
else at the same time and that other revision gets handled first.

#!/bin/sh

BANNED_AUTHORS="larry curly moe"
BANNED_DIVISOR=1000

SVNLOOK=/opt/local/bin/svnlook

REPO="$1"
TXN="$2"

AUTHOR=`$SVNLOOK author -t "$TXN" "$REPO"`
IS_OK_AUTHOR=1
for BANNED_AUTHOR in $BANNED_AUTHORS
do
        echo checking author $BANNED_AUTHOR against $AUTHOR 2>&1
        if [ "$AUTHOR" = "$BANNED_AUTHOR" ]
        then
                IS_OK_AUTHOR=0
        fi
done
if [ $IS_OK_AUTHOR -ne 0 ]
then
        exit 0
fi

HEAD_REV=`$SVNLOOK youngest "$REPO"`
NEXT_REV=$(($HEAD_REV+1))
IS_OK_REV=$(($NEXT_REV%$BANNED_DIVISOR))
if [ $IS_OK_REV -ne 0 ]
then
        exit 0
fi

echo "$AUTHOR may not commit revision $NEXT_REV" 1>&2
exit 1

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Aug 25 01:16:32 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.