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

Re: SVN: pre-commit, I give up. Help!

From: Ryan Schmidt <subversion-2007a_at_ryandesign.com>
Date: 2007-03-23 08:30:16 CET

On Mar 23, 2007, at 02:02, Ryan Schmidt wrote:

> On Mar 23, 2007, at 01:06, Res Pons wrote:
>
>> GREP='/bin/grep'

Make sure this is where grep actually is on your system. On mine,
it's in /usr/bin/grep.

>> echo -n "You must start your comment with a
>> bug number, aborting..." 1>&2
>
> Why are you suppressing the newline with -n?

Ah, now that I've played with it a bit, I see that Subversion
automatically prints a newline at the end.

So, this is a version that seems to work for me:

#!/bin/bash

# A pre-commit hook script to ensure that no changes are commited to the
# repository without a valid log message.

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

SVNLOOK='/opt/local/bin/svnlook'
GREP='/usr/bin/grep'

$SVNLOOK dirs-changed -t "$TXN" "$REPO" | $GREP '^testproject/trunk/'
> /dev/null

if [ $? -eq 0 ]; then
        
        # For testproject, make sure that the comment starts with a (bug)
number
        $SVNLOOK log -t "$TXN" "$REPO" | $GREP '^[[:digit:]]' > /dev/null
        
        if [ $? -ne 0 ]; then
                echo -n 'For this project, you must start your log message with a
bug number.' 1>&2
                exit 1
        fi
        
else
        
        # For other projects, no bug number necessary, just make sure the
comment isn't empty
        $SVNLOOK log -t "$TXN" "$REPO" | $GREP '[a-zA-Z0-9]' > /dev/null
        if [ $? -ne 0 ]; then
                echo -n 'You must enter some text in your log message.' 1>&2
                exit 1
        fi
        
fi

-- 
To reply to the mailing list, please use your mailer's Reply To All  
function
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Mar 23 08:30:49 2007

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.