#!/bin/bash

set -eu

#PATH=/home/gustavo/tools/subversion-1.9.0/subversion/svn:$PATH

TMPDIR=$(mktemp -d) || exit 1
echo "The files will be left in the $TMPDIR directory"

set -x

cd $TMPDIR

svnadmin create repo

svn --version | head -1

svn co file://$PWD/repo wc
cd wc
touch file.txt
svn add file.txt
svn ci -mx
svn up

if svn lock file.txt
then echo lock succeeded without a hook
else echo lock failed without a hook
fi

cat >../repo/hooks/pre-lock <<EOF
#!/bin/bash
exit 1
EOF
chmod +x ../repo/hooks/pre-lock

if svn lock file.txt
then echo lock succeeded with a failing hook
else echo lock failed with a failing hook
fi
