0

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" :)

1 Answers1

1

@ in Subversion URLs has a special meaning - but only for the final @. You need to URL-encode the @ as %40 in the URL, or append a trailing @ to the URL.

alroc
  • 27,574
  • 6
  • 51
  • 97
  • Can you give me please some code example? I'm using TortoiseSVN for commiting files from my PC to my SVN repository on my server with Debian and then SVN run post-commit script. I don't know where in this procedure is some URL. Thanks! – Jakub Škorpík Mar 12 '13 at 20:18
  • No, you have to do this in the hook script that you posted above. `file://$REPOS/$directory` is your URL. – alroc Mar 12 '13 at 20:23
  • Well I just after `file://$REPOS/$directory;` add a `@` like `file://$REPOS/$directory@;` and it works' Thank you very much! :) – Jakub Škorpík Mar 12 '13 at 20:36