Från Googlehemsida

Hoppa till: navigering, sök

[redigera] I'm managing a website in my repository. How can I make the live site automatically update after every commit?

This is done all the time, and is easily accomplished by adding a post-commit hook script to your repository. Read about hook scripts in Chapter 5 of the book. The basic idea is to make the "live site" just an ordinary working copy, and then have your post-commit hook script run 'svn update' on it.

In practice, there are a couple of things to watch out for. 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. In other words, the working copy must be owned by the same user that svnserve or apache runs as -- or at least the working copy must have appropriate permissions set.

If the server needs to update a working copy that it doesn't own (for example, user joe's ~/public_html/ area), one technique is create a +s binary program to run the update, since Unix won't allow scripts to run +s. Compile a tiny 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);
}

... and then chmod +s the binary, and make sure it's owned by user 'joe'. Then in the post-commit hook, add a line to run the binary.

If you have problems getting the hook to work, see "Why aren't my repository hooks working?".

Also, you'll probably want to prevent apache from exporting the .svn/ directories in the live working copy. Add this to your httpd.conf:

# Disallow browsing of Subversion working copy administrative dirs.
<DirectoryMatch "^/.*/\.svn/">
    Order deny,allow
    Deny from all
</DirectoryMatch>


[redigera] Why aren't my repository hooks working?

They're supposed to invoke external programs, but the invocations never seem to happen.

Before Subversion calls a hook script, it removes all variables -- including $PATH on Unix, and %PATH% on Windows -- from the environment. Therefore, your script can only run another program if you spell out that program's absolute name.

Debugging tips:

If you're using Linux or Unix, try running the script "by hand", by following these steps:

1. Use "su", "sudo", or something similar, to become the user who normally would run the script. This might be httpd or www-data, for example, if you're using Apache; it might be a user like svn if you're running svnserve and a special Subversion user exists. This will make clear any permissions problems that the script might have.

2. Invoke the script with an empty environment by using the "env" program. Here's an example for the post-commit hook:

$ env - ./post-commit /var/lib/svn-repos 1234

Note the first argument to "env" is a dash; that's what ensures the environment is empty. Replace /var/lib/svn-repos with your repo. The version number 1234 could be replaced with a period (.) if you want the latest version.

3. Check your console for errors.


[redigera] Sista lösningen

Om inget går din väg, du har provat allt. Svn fortsätter att fråga dig hur ang certifikat och lösenord. Då kan du testa att gå lokalt. Istället för https://svn.domain.se/sandbox så kan du skriva file:///home/svn/myproject/sandbox när du checkar ut projektet.