[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Hooks

From: Brendan Farr-Gaynor <brendan_at_resolutionim.com>
Date: Mon, 14 Dec 2009 21:10:28 -0500

So I think I'm a little bit closer, I had to checkout the repository
manually through the terminal to the web root, now when I manually run
my script I see that it indeed updates the web root, however the hook
doesn't seem to run when I change and update a file, I modified it to
add a line to a log:

#!/bin/sh

# POST-COMMIT HOOK
#
# The post-commit hook is invoked after a commit. Subversion runs
# this hook by invoking a program (script, executable, binary, etc.)
# named 'post-commit' (for which this file is a template) with the
# following ordered arguments:
#
# [1] REPOS-PATH (the path to this repository)
# [2] REV (the number of the revision just committed)
#
# The default working directory for the invocation is undefined, so
# the program should set one explicitly if it cares.
#
# Because the commit has already completed and cannot be undone,
# the exit code of the hook program is ignored. The hook program
# can use the 'svnlook' utility to help it examine the
# newly-committed tree.
#
# On a Unix system, the normal procedure is to have 'post-commit'
# invoke other programs to do the real work, though it may do the
# work itself too.
#
# Note that 'post-commit' must be executable by the user(s) who will
# invoke it (typically the user httpd runs as), and that user must
# have filesystem-level permission to access the repository.
#
# On a Windows system, you should name the hook program
# 'post-commit.bat' or 'post-commit.exe',
# but the basic idea is the same.
#
# The hook program typically does not inherit the environment of
# its parent process. For example, a common problem is for the
# PATH environment variable to not be set to its usual value, so
# that subprograms fail to launch unless invoked via absolute path.
# If you're having unexpected problems with a hook program, the
# culprit may be unusual (or missing) environment variables.
#
# Here is an example hook script, for a Unix /bin/sh interpreter.
# For more examples and pre-written hooks, see those in
# the Subversion repository at
# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/

#REPOS="$1"
#REV="$2"

#mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf

echo `date +"%Y%m%d-%H:%M:%S"` >> /var/log/svn_commit
/Library/WebServer/update_svn >> /var/log/svn_commit

--
Brendan Farr-Gaynor
On 2009-12-14, at 8:57 PM, Ryan Schmidt wrote:
>
> On Dec 14, 2009, at 18:33, Brendan Farr-Gaynor wrote:
>
>> SVN newbie here. I'm wondering if there is anyone out there running  
>> running Subversion on OS X Server (10.6)?
>
> Most assuredly.
>
>
>> I'm trying to use Subversion as a team web development solution and  
>> need to have committed files moved to our central apache web root  
>> for web browsing. I see this is a popular thing that people are  
>> looking for, but I'm having trouble getting my hook scripts to run  
>> and I'm sure it's got to be a permissions issue or something.
>>
>> Based on some tutorials I've found in different places I've done  
>> the following:
>>
>> I created a C program in XCode similar to this (update_svn):
>>
>> #include <stddef.h>
>> #include <stdlib.h>
>> #include <unistd.h>
>> int main(void)
>> {
>> execl("/usr/bin/svn", "svn", "update", "--username",
>> "YOURSVNUSER", "--password", "YOURSVNPASSWD",
>> "/Library/WebServer/", (const char *) NULL);
>> return(EXIT_FAILURE);
>> }
>
> I have no reason to believe it won't work, but why a C program, out  
> of curiosity? Wouldn't a 1-line shell script have done the trick?  
> That's what I've used in the past.
>
>
>> Created a post-commit script in my /hooks directory that has this:
>>
>> #/bin/sh
>> /Library/WebServer/update_svn
>>
>> Then modified the permissions as such:
>>
>> $ chown www /Library/WebServer/update_svn
>> $ chmod +s /Library/WebServer/update_svn
>>
>> $ chmod +s /myrepo/project/hooks/post-commit
>
> Why +s? I wouldn't expect you to need that. What you do need is +x.  
> Have you added that already?
>
>
>> However, it doesn't seem to run (files aren't moved) and I'm  
>> perplexed as to how to debug this, is there a log file somewhere?  
>> I'm not seeing anything in /var/log/ for svn?
>
> There is no log. Write one yourself if you want one, e.g.
>
> $ cat post-commit
> #/bin/sh
> /Library/WebServer/update_svn 2>>/var/log/update_svn.log
>
>
>> Does the above look right? Am I missing something? Has anyone out  
>> there had to do this on an OS X server that could provide some  
>> guidance?
>
> There should be nothing particularly unique about Mac OS X in this  
> regard; it should function just like any other UNIX-like OS.
>
>
>> I tried running the file from the shell as root (update_svn binary)  
>> and it reports that it 'Skipped: /Library/WebServer/' what does  
>> that mean?
>
> It means it doesn't think /Library/WebServer is a working copy. Is it?
>
>
Received on 2009-12-15 03:11:14 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.