1#!/bin/sh
2
3# PRE-COMMIT HOOK
4#
5# The pre-commit hook is invoked before a Subversion txn is
6# committed.  Subversion runs this hook by invoking a program
7# (script, executable, binary, etc.) named 'pre-commit' (for which
8# this file is a template), with the following ordered arguments:
9#
10#   [1] REPOS-PATH   (the path to this repository)
11#   [2] TXN-NAME     (the name of the txn about to be committed)
12#
13# The default working directory for the invocation is undefined, so
14# the program should set one explicitly if it cares.
15#
16# If the hook program exits with success, the txn is committed; but
17# if it exits with failure (non-zero), the txn is aborted, no commit
18# takes place, and STDERR is returned to the client.   The hook
19# program can use the 'svnlook' utility to help it examine the txn.
20#
21# On a Unix system, the normal procedure is to have 'pre-commit'
22# invoke other programs to do the real work, though it may do the
23# work itself too.
24#
25#   ***  NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT  ***
26#   ***  FOR REVISION PROPERTIES (like svn:log or svn:author).   ***
27#
28#   This is why we recommend using the read-only 'svnlook' utility.
29#   In the future, Subversion may enforce the rule that pre-commit
30#   hooks should not modify the versioned data in txns, or else come
31#   up with a mechanism to make it safe to do so (by informing the
32#   committing client of the changes).  However, right now neither
33#   mechanism is implemented, so hook writers just have to be careful.
34#
35# Note that 'pre-commit' must be executable by the user(s) who will
36# invoke it (typically the user httpd runs as), and that user must
37# have filesystem-level permission to access the repository.
38#
39# On a Windows system, you should name the hook program
40# 'pre-commit.bat' or 'pre-commit.exe',
41# but the basic idea is the same.
42#
43# The hook program typically does not inherit the environment of
44# its parent process.  For example, a common problem is for the
45# PATH environment variable to not be set to its usual value, so
46# that subprograms fail to launch unless invoked via absolute path.
47# If you're having unexpected problems with a hook program, the
48# culprit may be unusual (or missing) environment variables.
49#
50# Here is an example hook script, for a Unix /bin/sh interpreter.
51# For more examples and pre-written hooks, see those in
52# the Subversion repository at
53# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
54# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
55
56
57REPOS="$1"
58TXN="$2"
59
60# Make sure that the log message contains some text.
61SVNLOOK=/usr/local/bin/svnlook
62$SVNLOOK log -t "$TXN" "$REPOS" | \
63   grep "[a-zA-Z0-9]" > /dev/null || exit 1
64
65# Check that the author of this commit has the rights to perform
66# the commit on the files and directories being modified.
67commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
68
69# All checks passed, so allow the commit.
70exit 0
71