SVN Post Commit script to update php code

If you have for example a development box eg: http://mysite.com/dev/
and you are storing all your code in svn via http://mysite.com/svn/
then you can create an svn post commit script to update /dev/ every time someone makes a change to the svn repo.

Go to the /var/www/svn/your_repo/hooks/ directory (or wheverever it is located)
create a new file called post-commit that looks like this:

#/bin/sh
/var/www/html/update_svn

create the update_svn executable:

$ vi update_svn.c 
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
  execl("/usr/bin/svn", "svn", "update", "--username",
"YOURSVNUSER", "--password", "YOURSVNPASSWD",
"/var/www/html/dev/",  (const char *) NULL);
  return(EXIT_FAILURE);
}
$ gcc update_svn.c -o /var/www/html/update_svn
$ chown YOURWEBUSER: /var/www/html/update_svn
$ chmod +s /var/www/html/update_svn
Now after someone commits something to the repo, it will run that executable as YOURWEBUSER which will update the svn repository located in /var/www/html/dev/ automatically...
Leave a Comment

Yes, send me an email when a new comment is posted.

The avatars shown next to comments are Gravatars. Click here to get a Gravatar account for free and any other site that supports it will show your avatar too!