This is how to quicky setup a SVN post commit script. This method will push the latest version of code your website after each SVN commit. Useful to test the code on a shared production box after each commit.
Example: http://mysite.com/dev/ – this is where the code will be copied to after each SVN commit so you can test it.
First step is to checkout a copy of the code into your /dev/ directory. Example:
$ cd /var/www/dev/
$ svn checkout http://mysite.com/svn/project .
Now you should be able to access http://mysite.com/dev/ and test to see if the code works.
Next step is to automate a “svn update” after each commit to the SVN repo.
Go to your SVN hooks directory ( eg: /var/www/svn/your_repo/hooks/ ) and create a new file called post-commit that looks like this:
Now create the update_svn executable referenced in the above script:
$ vi update_svn.c
execl("/usr/bin/svn", "svn", "update", "--username",
"YOURSVNUSER", "--password", "YOURSVNPASSWD",
"/var/www/dev/", (const char *) NULL);
$ gcc update_svn.c -o /var/www/update_svn
$ chown YOURWEBUSER: /var/www/update_svn
$ chmod +s /var/www/update_svn
after someone commits something to the repo, it will run that
executable as YOURWEBUSER which will update the svn repository located
in /var/www/dev/ automatically…
Note: SEE ALSO: what you need to do to prevent a post commit error: svn: MERGE of ‘/some/file’: 200 OK error