[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: Waynn Lue <waynnlue_at_gmail.com>
Date: Sat, 19 Jul 2008 22:42:47 -0700

>
> 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
>
Excellent, thanks so much for the help, this worked like a charm. Two quick
questions so I understand what's going on, why the "...." at the beginning
of the regex? Shouldn't (.*/) be enough? Second, what's $? map to?
Searching "$? bash" didn't help.

Thanks again,
Waynn
Received on 2008-07-20 07:43:16 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.