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

RE: pre-commit hooks does not show any output

From: Daevid Vincent <daevid_at_daevid.com>
Date: Fri, 16 May 2008 14:47:55 -0700

Here's another little trick a friend showed me to save you the hassle of
appending 1>&2 to every echo line.

Put this at the top of your script somewhere:

 

# redirect all output to stderr rather than line by line

exec 1>&2

 

then ALL echo's will be redirected for you. J

 

I've also updated my script some more (find online at the same link) to
prevent .mine and .rXXX files:

http://www.daevid.com/content/examples/snippets.php

 

 

From: prakash tiwary [mailto:prakash.tiwary_at_gmail.com]
Sent: Thursday, May 15, 2008 9:57 PM
To: Hari Kodungallur
Cc: Daevid Vincent; users_at_subversion.tigris.org
Subject: Re: pre-commit hooks does not show any output

 

Daevid, Hari
    Thanks for taking all those effort. Its work with "1>&2" which
redirects the output stderr in bash.

Regards,
Prakash
  

On Fri, May 16, 2008 at 2:32 AM, Hari Kodungallur <hkodungallur_at_gmail.com>
wrote:

 

On Thu, May 15, 2008 at 12:38 PM, Daevid Vincent <daevid_at_daevid.com> wrote:

Yeah, I struggled last night for several hours trying to find what would
seem to be a pretty standard pre-commit script. I would have expected the
examples would be more verbose and have some "uncomment this line, make sure
this path is correct, and you're golden" type of stuff in there. Mine had a
reference to "commit-access-control.pl "$REPOS" "$TXN"
commit-access-control.cfg || exit 1" . I don't even have a file named
"commit-access-control.pl" on my entire file system !?!

commit-access-control.pl is part of the source distribution.
Note that this is provided in a file that is only a template. If it did
mention this fact (that the perl script is part of the source distribution),
it would be helpful. May be you should send a request to the dev. However,
I don't think it is a huge deal. Lot of people of already figured it out :-)
 

 

Anyways Hari, Hopefully this will save you some gray hair pulling.

 

The first trick that nobody mentions is that you have to redirect all output
to stderr (?!) so you have to do this kind of redirection annoyance:

 

echo "A commit log message is required." 1>&2

The documentation for pre-commit says that: "Anything printed to stderr is
marshalled back to the client" in case of non-zero exit state.
This (1>&2) is a common way to redirect output stderr in bash.

[Basically, I don't understand the "(?!)" and why it is an annoyance, if the
documentation asks you to print things to stderr]

 

The next thing that took me forever to figure out (and find examples on the
net) is that you have to do this completely convoluted "SVNLOOK" thing to
get the filenames you are trying to check. GRRR.

 

You are correct that we need to use SVNLOOK to get the check-in details.
However, (again) I am not quite sure why it is convoluted. This is an
extremely simple to use set of commands.

  

Another huge issue I found is that almost all the examples are in Python! I
would have liked to find a PHP one ideally, or again, at least have the
default .tmpl ones (in Bash) be more explicit.

There are a couple of examples in bash. Other examples in the svn repository
mentioned in the template script are python. There are actually a few server
side scripts in perl and ruby as well that is part of the source
distribution (commit-access-control file is one of them). They all are
designed to be called from hooks.

But I believe the idea is to provide the user with information on how you
can use the hooks to accomplish different things. Once you have the info,
you are free to use any language you wish. [Unless some sort of 'web' is
involved, I have not too many instances of php being used purely for
scripting; but I could be wrong.].
 

 

Long story short, here is what I came up with so far in the five plus hours
I spent last night on it

(I will keep it updated as I learn more and find more interesting/useful
parts to add to the script):

http://www.daevid.com/content/examples/snippets.php

I think the information you provide are very useful. It is great that you
have published it in your website.

Thanks,
-Hari

 
Received on 2008-05-16 23:48:57 CEST

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.