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

Re: Fail commit if certain text in the commit

From: Christopher Ness <chris_at_nesser.org>
Date: 2005-06-09 16:44:56 CEST

On Thu, 2005-06-09 at 17:57 +1000, Steve Williams wrote:
> I have tried adding the following to the template pre-commit hook
> (server running on RH9).
>
> if $SVNLOOK diff -t "$TXN" "$REPOS" | grep -i "nocommit" >/dev/null
> then (echo "Contains nocommit keyword"; exit 1)
> fi
>
> but it doesn't seem to catch the keyword. Is it my Bash scripting (i'm
> a total newbie to Bash) or my use of the pre-commit hook? The
> pre-commit hook currently works for catching empty log messages, but I
> have no idea why this one is not working.

A good start! Without checking your syntax, but looking at the meat of
the problem you appear to be checking the diff of the transaction.

I don't think that is what you want. Try looking at the properties set
in the files that changed.

In 1.2.0 there is `svnlook changed` which will list the files that
changed in the transaction and then loop over that list to see if the
keyword is set on any of those files.

One thing that comes to mind is how do you allow commits to add and
remove these properties which is a valid action. You need to have a
little more logic than just checking for the property. I haven't done
this before so you'll have to read up on it in "the book".

I would also loop over the entire list instead of exiting on the first
one found. This way you print the error message with ALL the paths that
have that keyword set so developers don't waste time finding one file at
a time.

Cheers,
Chris

-- 
Wireless Group,
McMaster University
finger.localdomain
10:33:38 up 1:22, 1 user, load average: 0.02, 0.01, 0.00
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Jun 9 16:48:40 2005

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