source: XIOS/tools/FCM/examples/svn-hooks/pre-commit @ 1520

Last change on this file since 1520 was 81, checked in by ymipsl, 12 years ago

ajout FCM 1.5

File size: 3.3 KB
Line 
1#!/bin/ksh
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
56REPOS="$1"
57TXN="$2"
58
59# Check that the author of this commit has the rights to perform
60# the commit on the files and directories being modified.
61script=$REPOS/hooks/svnperms.py
62config=$REPOS/hooks/svnperms.conf
63if [[ -x $script && -a $config ]]; then
64  $script -r "$REPOS" -t "$TXN" -f $config || exit 1
65elif [[ -L $config ]]; then
66  echo \
67"Error: $config is missing.
68Please contact your system manager to fix this problem." >&2
69  exit 1
70fi
71
72# Check that the size of the transaction does not exceed 5Mb
73size=$(du -b -s $REPOS/db/transactions/$TXN.txn | cut -f 1)
74if (($size > 5242880)); then
75  size=$(du -h -s $REPOS/db/transactions/$TXN.txn | cut -f 1)
76  echo \
77"Your changeset requires a disk space ($size) exceeding our 5Mb limit.
78Please contact the FCM team if you need to bypass this restriction." >&2
79  exit 1
80fi
81
82# All checks passed, so allow the commit.
83exit 0
Note: See TracBrowser for help on using the repository browser.