~allison/ubuntu/raring/libsvn-web-perl/fix-for-1106378

« back to all changes in this revision

Viewing changes to t/repos/hooks/pre-unlock.tmpl

  • Committer: Package Import Robot
  • Author(s): Hilko Bengen
  • Date: 2012-10-22 21:08:14 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20121022210814-5wru25mlw6dakkr8
Tags: 0.63-1
* New Upstream version
* Updated dependencies
* Switched to Debhelper 8
* Set locale for running tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# PRE-UNLOCK HOOK
 
4
#
 
5
# The pre-unlock hook is invoked before an exclusive lock is
 
6
# destroyed.  Subversion runs this hook by invoking a program 
 
7
# (script, executable, binary, etc.) named 'pre-unlock' (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] PATH         (the path in the repository about to be unlocked)
 
12
#   [3] USER         (the user destroying the lock)
 
13
#   [4] TOKEN        (the lock token to be destroyed)
 
14
#   [5] BREAK-UNLOCK (1 if the user is breaking the lock, else 0)
 
15
#
 
16
# The default working directory for the invocation is undefined, so
 
17
# the program should set one explicitly if it cares.
 
18
#
 
19
# If the hook program exits with success, the lock is destroyed; but
 
20
# if it exits with failure (non-zero), the unlock action is aborted
 
21
# and STDERR is returned to the client.
 
22
 
 
23
# On a Unix system, the normal procedure is to have 'pre-unlock'
 
24
# invoke other programs to do the real work, though it may do the
 
25
# work itself too.
 
26
#
 
27
# Note that 'pre-unlock' must be executable by the user(s) who will
 
28
# invoke it (typically the user httpd runs as), and that user must
 
29
# have filesystem-level permission to access the repository.
 
30
#
 
31
# On a Windows system, you should name the hook program
 
32
# 'pre-unlock.bat' or 'pre-unlock.exe',
 
33
# but the basic idea is the same.
 
34
#
 
35
# Here is an example hook script, for a Unix /bin/sh interpreter:
 
36
 
 
37
REPOS="$1"
 
38
PATH="$2"
 
39
USER="$3"
 
40
 
 
41
# If a lock is owned by a different person, don't allow it be broken.
 
42
# (Maybe this script could send email to the lock owner?)
 
43
 
 
44
SVNLOOK=/usr/bin/svnlook
 
45
GREP=/bin/grep
 
46
SED=/bin/sed
 
47
 
 
48
LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
 
49
            $GREP '^Owner: ' | $SED 's/Owner: //'`
 
50
 
 
51
# If we get no result from svnlook, there's no lock, return success:
 
52
if [ "$LOCK_OWNER" = "" ]; then
 
53
  exit 0
 
54
fi
 
55
 
 
56
# If the person unlocking matches the lock's owner, return success:
 
57
if [ "$LOCK_OWNER" = "$USER" ]; then
 
58
  exit 0
 
59
fi
 
60
 
 
61
# Otherwise, we've got an owner mismatch, so return failure:
 
62
echo "Error: $PATH locked by ${LOCK_OWNER}." 1>&2
 
63
exit 1