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

Re: post-commit question

From: Ian Schneider <Ian.Schneider_at_ars.usda.gov>
Date: 2004-05-27 21:09:55 CEST

On Thursday 27 May 2004 11:36 am, Jeroen Coumans wrote:
> Ben Collins-Sussman said the following on 26-05-2004 20:53:
> > On Wed, 2004-05-26 at 11:07, Jeroen Coumans wrote:
> >>Eg. if some commits to /branches/client1/, the post-commit script would
> >>export /branches/client1/ to /www/client1/
> >
> > Of course it's possible. Have your post-commit script use 'svnlook' to
> > examine the commit that just happened, and act accordingly.
>
> Aha, ok, thanks! My scripting is not very good, but I hope I can manage
> this by myself. What would be the best way to test and debug the
> post-commit hook? I have setup a test repository to test it out, but it
> doesn't show me the output of the script. I have the following:
>
> #!/bin/sh
> set -x
>
> REPOS="$1"
> REV="$2"
> branch='svnlook changed /subversion/mambo/ | cut -d / -f 3'
>
> echo "REPOS = $REPOS"
> echo "REV = $REV"
> echo "branch = $branch"
>
> How do I view the output?

I also found this quite frustrating at times.
For one, unless the user that the script executes under (in my case , Fedora
Core uses apache) has a login shell (which sets path,etc.) then you will have
to use absolute paths, like /bin/echo or come up with a scheme for getting
paths (like sourcing a common file)

I do stuff like this:
<command> >> /tmp/hook_log 2 >&1

This will append output from your command to the /tmp/hook_log file
redirecting both stdout and stderr.

Note that if you want output to make it to subversion, i.e. Cannot commit
because you didn't do something/don't have permissions, it must be on stderr.

Here is a pre-commit check for committing to tags:

/usr/bin/svnlook changed -t $2 $1 | grep "^U\W*tags" && /bin/echo "CANNOT
COMMIT TO TAGS!!!" 1>&2 && exit 1

The
/bin/echo <message> 1>&2
does a redirect to stderr.

Hope this helps,
Ian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu May 27 21:10:54 2004

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.