SVN pre-commit hooks with perl tests

Dominic Mitchell dom at
Wed Jan 11 21:06:03 GMT 2006

Paul Makepeace wrote:
> Je 2006-01-11 18:36:47 +0000, jesse skribis:
>> On Wed, Jan 11, 2006 at 06:30:47PM +0000, Paul Makepeace wrote:
>>> Looking into implementing pre-commit hook tests in SVN to prevent
>>>  check-ins when a subset of tests fail. One problem that's come 
>>> up is that sometimes it's useful to know the working directory, 
>>> e.g. to load files. SVN's pre-commit template says the working 
>>> dir is undefined.
>>> Has a) anyone done this (didn't find any examples online) b) know
>>>  how to get the user's CWD?
>> What does "the user's cwd" mean when you're doing a commit via HTTP
>>  or SSH?
> My terminology was sloppy, yes. What I mean is what you might 
> intuitively expect: the root of the to-be-checked-in project.

That doesn't exist.  You /may/ get lucky if the user is checking in via
a file:/// url, but even then I doubt it.  And when you're checking in
over the network, you simply don't have access to the users working copy.

>> Maybe the right thing is to do a checkout into a sandbox?
> I hope not.

The only alternative to that is using tools like svnlook to look inside
the repository.

Subversion doesn't have a checked out repository at all on the server.
It's not even like CVS where you can fudge bits of it by looking in the
repository for the ,v files.

More information on writing  hook scripts:

Looking at the pre-commit documentation there, you should be able to use
svnlook --transaction to see what's been checked in.


More information about the mailing list