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

Re: Post svn hook

From: Ryan Schmidt <subversion-2014_at_ryandesign.com>
Date: Fri, 16 May 2014 19:12:18 -0500

On May 15, 2014, at 17:51, Havlovick, Ron wrote:

> I am a newbie and I am more than a bit confused.
> Perhaps ya'll could tell me something. (Other than to …..)
>
> I am on Windows using tortoise svn.
>
> Here's what I want to do, and I am trying to figure out exactly how to do it.
> Please bear with me:
>
> When I commit a file into the repository, I want the entire repository directory(folder) to be checked out to a "golden directory(folder)".
> I do not care if it over writes any existing file in that golden directory(folder).
> Create an empty text file in the golden directory(folder).
> In the empty text file write to it the revision number of the repository directory(folder) and the date of the last commit (basically the date stamp of the repository directory(folder).
>
> I can write a perl script to basically copy files from one directory to another (golden).
> read the data stamp of the directory(folder). ctime(stat($directory….)->my_time)
>
> What has got me baffled is:
> How to get the revision number of the repository directory(folder). (Is this just a regular folder on the server and I just have the path \\server\directory wrong)
> How to get the date stamp of that repository directory(folder). (This could be if I have the path wrong then I am trying to read statistics on nothing.)
>
> Assuming I have the perl script correct, where do I put the perl script in what post_hook or post_commit?
> Do I call the perl script within the post_commit { function or what…
> And where do I put the combined perl script post_hook script? (In the svn directory on my PC or on the server)
>
> When I run the perl script on a local directory via the command prompt, everything works. (But I am not pointing to the repository, just a local c:\folder.)

Look in the repository directory on the server. You should see among other things a "hooks" directory, containing sample scripts for each of the events for which Subversion can call hook scripts. These sample scripts have names ending in ".tmpl". They're written in Bash, which is for UNIX systems and won't usually work on Windows; for Windows, you'd need to write a batch script or a compiled executable. You'd place this script in the hooks directory, named the same as the relevant sample script, except without the ".tmpl" extension and with an extension appropriate for the type of file (e.g. "post-commit.bat" for a batch script, "post-commit.exe" for a compiled executable). Some other extensions are recognized by Subversion server on Windows as well, although I don't believe .pl is one of them, so you should probably write a small batch script or exe that runs your perl script.

The comments in the sample scripts tell you what arguments Subversion server supplies to the hook script when it runs it. For example, the post-commit script is given the repository path on disk as the first argument and the just-committed revision number as the second argument. So in Bash on UNIX, the repository path would be available as "$1" and the revision as "$2"; I don't know how that works in Windows batch files but there's probably a similar way to do that. So in Bash on UNIX, I could use that information to get the date of the commit by running "svnlook date $1 -r $2".
Received on 2014-05-17 03:14:54 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.