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

Re: Hooks

From: Chuck Holzwarth <chuck_holzwarth_at_yahoo.com>
Date: Tue, 2 Sep 2008 06:32:31 -0700 (PDT)

I wrote my Java pre-commit hook to use command line arguments and put defaults in the program. This way, I can develop and test on my local system and install and use on the official subversion system. Here is what my pre-commit.bat file looks like:

PATH=C:\j2sdk1.4.2_13\bin
set CLASS_PATH=C:\j2sdk1.4.2_13\lib
java -jar C:/Repositories/svn_repos/hooks/espsvn.jar SVN_REPOS:%1 TRANSACTION:%2 DEBUG:0 "SVNCMD:C:/Program Files/Subversion/bin/svnlook.exe" "PROPFILE:C:/Repositories/svn_repos/hooks/precommit.properties"

 
The Java call is on one line but may appear on more than one in your email.

Thank you,
Chuck Holzwarth
(804) 403-3478 (home)
(804) 305-4040 (cell)

----- Original Message ----
From: Giulio Troccoli <Giulio.Troccoli_at_uk.linedata.com>
To: "Gourlay, Colin" <cg1_at_ebs.hw.ac.uk>; "users_at_subversion.tigris.org" <users_at_subversion.tigris.org>
Sent: Tuesday, September 2, 2008 6:09:01 AM
Subject: RE: Hooks

>

Linedata Services (UK) Ltd
Registered Office: Bishopsgate Court, 4-12 Norton Folgate, London, E1 6DB
Registered in England and Wales No 3027851 VAT Reg No 778499447

-----Original Message-----

> From: Gourlay, Colin [mailto:cg1_at_ebs.hw.ac.uk]
> Sent: 02 September 2008 11:03
> To: users_at_subversion.tigris.org
> Subject: Hooks [auto-ip]
>
> Hello.
>
> I am attempting to create a hook (pre-commit) that will stop users from
> committing a specific version of Microsoft Word file.
>
> Specifically looking to block Word version 2007 which happens to have a
> .docx file extension and force them to commit versions in older versions
> with a .doc version. This is to ensure that everyone can work with the
> documents - irrespective of the version they have installed on their
> desktop.
>
> Subversion version 1.4.4 (r25188) is running on Windows 2003 server - so
> attempted to put something together with DOS batch files, also tried
> writing a c# console application - all following the templates as a guide
> and with partial success, in that I am only obtaining minimal information
> about the transaction not the file(s) being committed.
>
> Can anyone please help?
>
> Sample code (c#) that I have used follows:
>
> static int Main(string[] args)
> {
> System.Diagnostics.Process p = new
> System.Diagnostics.Process();
> p.StartInfo.FileName = "svnlook";
> p.StartInfo.UseShellExecute = false;
> p.StartInfo.RedirectStandardOutput = true;
> p.StartInfo.Arguments = @" changed -t " + args[1] +
> @"D:\SubversionRepos\ProjectName";
> p.Start();
> p.WaitForExit();
>
> string output = p.StandardOutput.ReadToEnd();
> output = output.ToLower();
>
> System.IO.StreamWriter sw = new
> System.IO.StreamWriter(@"D:\PreCommit.txt", true,
> System.Text.Encoding.Default);
> sw.WriteLine(string.Join("|", args));
> sw.WriteLine("output = " + output);
> sw.Close();
>
> if(output.Contains("docx"))
> {
> return 1;
> }
> return 0;
>
> }

My repository is on Linux so I don't have direct experience, but I read many times on this mailing list that you should use a full path for all your programmes. Have you tried using

p.StartInfo.FileName = "C:\wherever\svn\has\been\installed\svnlook.exe";

or something like that?

Giulio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org

      
Received on 2008-09-02 15:33:01 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.