My goal here was to update a dev server anytime I commit a file. The simpliest way to do that seemed to create a post-commit hook. The difficulty though, came from file ownership and user issues. Basically, the post-commit script is executed as Apache : www-data on debian. And this user, on my setup, didn’t have the rights to update … I tried to use su but that failed with “su can only be run in the terminal”. I installed and tried with sudo and that failed with “sudo no tty present and no askpass program specified”.
So, here is the solution.
Go to your repository (ie /var/repository/) and cd into the hooks directory
You will see a post-commit.tmpl file. That is an example Create a post-commit file and enter the following
sudo -u your_user /usr/bin/svn update /var/www/project/ --username your_svn_user --password your_svn_password
Now, make sure this file can be executed by Apache
chown www-data:www-data post-commit
chmod 744 post-commit
Time to check the sudo part of this
aptitude install sudo #if you do not have it already
And give Apache the right to sudo to use svn without password
# give root editing rights
chmod 740 sudoers
#add this line
%www-data ALL=(ALL) NOPASSWD:/usr/bin/svn
#restore the rights
chmod 440 sudoers
That was it for me.
An interesting alternative solution.