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

Hook problems

From: David Ameiss <david_at_ameissnet.com>
Date: 2004-11-22 21:41:06 CET

I'm running into problems with a pre-commit hook. The intent is to 1)
make sure something was entered for the log message, and 2) prevent
commits to anything in the tags subdirectory.

Following the suggestion in an earlier message from this list, my
pre-commit is:

# The pre-commit hook is invoked before a Subversion txn is
# committed. Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
# [1] REPOS-PATH (the path to this repository)
# [2] TXN-NAME (the name of the txn about to be committed)
# The default working directory for the invocation is undefined, so
# the program should set one explicitly if it cares.
# If the hook program exits with success, the txn is committed; but
# if it exits with failure (non-zero), the txn is aborted and no
# commit takes place. The hook program can use the 'svnlook'
# utility to help it examine the txn.
# On a Unix system, the normal procedure is to have 'pre-commit'
# invoke other programs to do the real work, though it may do the
# work itself too.
# This is why we recommend using the read-only 'svnlook' utility.
# In the future, Subversion may enforce the rule that pre-commit
# hooks should not modify txns, or else come up with a mechanism
# to make it safe to do so (by informing the committing client of
# the changes). However, right now neither mechanism is
# implemented, so hook writers just have to be careful.
# Note that 'pre-commit' must be executable by the user(s) who will
# invoke it (typically the user httpd runs as), and that user must
# have filesystem-level permission to access the repository.
# On a Windows system, you should name the hook program
# 'pre-commit.bat' or 'pre-commit.exe',
# but the basic idea is the same.
# Here is an example hook script, for a Unix /bin/sh interpreter:


# Make sure that the log message contains some text.
${SVNLOOK} log -t "$TXN" "$REPOS" | \
   grep "[a-zA-Z0-9]" > /dev/null || exit 1

# Don't allow commits to anything in the "tags" directory
${SVNLOOK} changed -t $2 $1 | grep "^U\W*tags" > /dev/null && /bin/echo "Cannot commit to tags" 1>&2 && exit 1

## Check that the author of this commit has the rights to perform
## the commit on the files and directories being modified.
#commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1

# All checks passed, so allow the commit.
exit 0

This is svn 1.0.8, running via DAV on a Gentoo Linux server.

Now, any commits fail with:

"Can't create null stdout for hook '/var/svn/xxx/hooks/pre-commit';
Permission denied"

AFAIK all the paths are correct, as are the permissions on pre-commit.

Any ideas? Thanks!

David Ameiss
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Nov 23 20:43:05 2004

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.