I'am using this post-commit script (it's not my work, I have it from here).
#!/bin/bash
REPOS="$1"
REV="$2"
# A - Item added to repository
# D - Item deleted from repository
# U - File contents changed
# _U - Properties of item changed; note the leading underscore
# UU - File contents and properties changed
# Files and directories can be distinguished, as directory paths are displayed with a trailing "/" character.
LOOK=/usr/bin/svnlook
SVN=/usr/bin/svn
DEV=/var/www/my_web
cd /var/tmp/svn
for changes in `$LOOK changed $REPOS | awk '{print $1 "=" $2;}'`;
do
len=${#changes}
idx=`expr index "$changes" =`;
directory=${changes:$idx};
action=${changes:0:$idx-1};
if [ ${changes:len-1} = '/' ]
then
case "$action" in
"A" ) \
mkdir --mode=775 -p $DEV/$directory;
chown www-data:www-data $DEV/$directory;
chmod 775 $DEV/$directory;
;;
"D" ) \
rmdir $DEV/$directory;
;;
esac
else
case "$action" in
"A"|"U"|"UU" ) \
$SVN export --force --non-interactive -r HEAD -q file://$REPOS/$directory;
BASE=`basename $directory`;
DIR=`dirname $directory`;
chown www-data:www-data $BASE;
chmod 775 $BASE;
mkdir --mode=775 -p $DEV/$DIR;
cp -f --preserve=ownership $BASE $DEV/$DIR;
unlink $BASE;
;;
"D" ) \
rm -f $DEV/$directory;
;;
esac
fi
done
exit 0
Script works perfect - adding/removing files, folder, setting permissions but if I commit file with name for example "@layout.latte" I can see this file in SVN tree on my server (so commit works fine) but post-commit script doesn't copy this file to my /var/www/my_web folder.
Does anyone know why? Thank you very much! I was looking everywhere, but I didn't have any luck.
EDIT: It also doesn't work for files like "test@test.txt". It's because of "@", but I don't know, how to fix it. I think something like escaping could help, but I'm really not a "bash guy" :)