Abstract
This tutorial explains how to update a staging site whenever there is a commit to the SVN repository. This assumes basic knowledge of Subversion, Apache and C and that the staging site is running a working copy checked out from the repository.
**Problem & Solution
**
When working close with designers or other non-coders it’s often most productive to be able to make quick changes live to the box serving up the dev site, then to commit a change then update the server over and over. The bigger issue is that there is now modified code on the dev site that’s not revisioned with subversion. To solve this problem we are going to update the codebase for the development site whenever anyone commits changes to the subversion repository.
update_svn
update_svn is a C program that will make a call to the svn command with our designated username and password and update the working copy. This program should live inside your applications directory.
update.c
#include <stddef.h> #include <stdlib.h> #include <unistd.h> int main(void) { execl("/usr/bin/svn", "svn", "update", "--username", "USERNAME", "--password", "PASSWORD", "/var/www/website/", (const char *) NULL); return(EXIT_FAILURE); } |
Compile and add permissions
gcc svn_update.c -o /var/www/website/update_svn<br /> chmod +s update_svn
Subversion post-commit hook
In our subversion repository’s post-commit script we want to add a call to update_svn. Add the following line to your post-commit script:
/var/www/website/update_svn
Resources: