source: branches/0.7-stable/test/repo/hooks/pre-commit.tmpl @ 1030

Last change on this file since 1030 was 248, checked in by Peter Johansson, 15 years ago

fixes #125

File size: 2.3 KB
Line 
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# Here is an example hook script, for a Unix /bin/sh interpreter:
44
45REPOS="$1"
46TXN="$2"
47
48# Make sure that the log message contains some text.
49SVNLOOK=/usr/local/bin/svnlook
50$SVNLOOK log -t "$TXN" "$REPOS" | \
51   grep "[a-zA-Z0-9]" > /dev/null || exit 1
52
53# Check that the author of this commit has the rights to perform
54# the commit on the files and directories being modified.
55commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
56
57# All checks passed, so allow the commit.
58exit 0
Note: See TracBrowser for help on using the repository browser.