svn update not working in post commit

Gabriel Solomon picture Gabriel Solomon · Mar 30, 2009 · Viewed 13.5k times · Source

I am trying to implement a post-commit hook to update a working copy. As far as i can figure out the post commit hook is being run (I wrote something in a file to verify it) but the update command was not run.

At first I did

cd /home/user/working/copy
svn update

but that didn't work, then I read you have to give the full path to svn:

cd /home/user/working/copy
/usr/bin/svn update

but still it failed to work.

I changed permisions to 777 and have run the script in an empty enviroment ... and it works.

Answer

StackKrish picture StackKrish · Mar 30, 2009
#!/bin/bash
/usr/bin/svn update /home/user/working/copy

The above code should work as a post-commit hook.

Add --username & --password options if needed.

Edit:

See http://subversion.tigris.org/faq.html#website-auto-update

The server program performing the commit (svnserve or apache) is the same program that will be running the post-commit hook script. That means that this program must have proper permissions to update the working copy.

If the 'working copy' that needs to be updated is owned by the same user, then you need NOT worry about username & password.

The Subversion FAQ suggests using Setuid with the following C program.

#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
execl("/usr/local/bin/svn", "svn", "update", "/home/joe/public_html/",
    (const char *) NULL);
return(EXIT_FAILURE);
}