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

Re: any "must-have" hooks to implement on svn server?

From: Ryan Schmidt <subversion-2008c_at_ryandesign.com>
Date: Sun, 20 Jul 2008 00:23:50 -0500

On Jul 19, 2008, at 09:22, Waynn Lue wrote:

> There are files that should exist in each developer's environment
> called dbsecret.php.inc and reality.php.inc, and I want to make
> sure no one tries to check in a file named that. This was my
> attempt in pre-commit to fix it, but it doesn't seem to work. Any
> ideas?
>
> $SVNLOOK changed -t "$TXN" "$REPOS" | \
> grep -E "dbsecret.php.inc|reality.php.inc" > /dev/null || exit 1

You're telling the script to exit if the filename is NOT
dbsecret.php.inc or reality.php.inc, when actually you want the
script to exit if the filename IS dbsecret.php.inc or
reality.php.inc. Change "||" to "&&" to fix this.

But you should also escape the special characters in the filenames
(in this case the periods) and anchor the search to the beginning and
end of the string (so you don't match files whose names merely
CONTAIN dbsecret.php.inc or reality.php.inc). And you will probably
want to print message to the user explaining what went wrong.

$SVNLOOK changed -t "$TXN" "$REPOS" | \
        grep -E "^....(.*/)?(dbsecret\.php\.inc|reality\.php\.inc)$" > /dev/
null
if [ $? -eq 0 ]; then
        echo "You con't commit files named dbsecret.php.inc or
reality.php.inc" 1>&2
        exit 1
fi
exit 0

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-07-20 07:24:36 CEST

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.