Edgewall Software

Ticket #1602: pre-commit.cmd

File pre-commit.cmd, 2.6 KB (added by coreywangler@…, 3 years ago)

fixed .com file for launching the corresponding python hook script (from 0.8-stable/contrib/) in windows

Line 
1@ECHO OFF
2SET REPOS=%1
3SET TXN=%2
4
5SET SVNREP_DIR=C:\svnrep\___SVN_REPOSITORY_NAME_HERE___
6SET TRACDB_DIR=C:\tracdb\______TRAC_DB_NAME_HERE______
7
8SET PYTHON_DIR=C:\Python23
9SET SVN_DIR=C:\Program Files\Subversion
10
11REM PRE-COMMIT HOOK (for a Windows CMD.exe interpreter)
12REM
13REM The pre-commit hook is invoked before a Subversion txn is
14REM committed.  Subversion runs this hook by invoking a program
15REM (script, executable, binary, etc.) named 'pre-commit' (for which
16REM this file is a template), with the following ordered arguments:
17REM
18REM   [1] REPOS-PATH   (the path to this repository)
19REM   [2] TXN-NAME     (the name of the txn about to be committed)
20REM
21REM The default working directory for the invocation is undefined, so
22REM the program should set one explicitly if it cares.
23REM
24REM If the hook program exits with success, the txn is committed; but
25REM if it exits with failure (non-zero), the txn is aborted, no commit
26REM takes place, and STDERR is returned to the client.   The hook
27REM program can use the 'svnlook' utility to help it examine the txn.
28REM
29REM On a Unix system, the normal procedure is to have 'pre-commit'
30REM invoke other programs to do the real work, though it may do the
31REM work itself too.
32REM
33REM   ***  NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT  ***
34REM   ***  FOR REVISION PROPERTIES (like svn:log or svn:author).   ***
35REM
36REM   This is why we recommend using the read-only 'svnlook' utility.
37REM   In the future, Subversion may enforce the rule that pre-commit
38REM   hooks should not modify the versioned data in txns, or else come
39REM   up with a mechanism to make it safe to do so (by informing the
40REM   committing client of the changes).  However, right now neither
41REM   mechanism is implemented, so hook writers just have to be careful.
42REM
43REM Note that 'pre-commit' must be executable by the user(s) who will
44REM invoke it (typically the user httpd runs as), and that user must
45REM have filesystem-level permission to access the repository.
46REM
47REM On a Windows system, you should name the hook program
48REM 'pre-commit.bat' or 'pre-commit.exe',
49REM but the basic idea is the same.
50REM
51REM Here is an example hook script, for a Windows CMD.exe interpreter:
52
53SET HOOKS_DIR="%SVNREP_DIR%\hooks"
54REM SET TRAC_ENV="%TRACDB_DIR%\db\trac.db"
55SET TRAC_ENV="%TRACDB_DIR%"
56
57SET PYTHON="%PYTHON_DIR%\python.exe"
58SET SVN="%SVN_DIR%\bin\svn.exe"
59SET SVNADMIN="%SVN_DIR%\bin\svnadmin.exe"
60SET SVNLOOK="%SVN_DIR%\bin\svnlook.exe"
61
62FOR /F "usebackq delims==" %%i IN (`%%SVNLOOK%% log -t %TXN% %REPOS%`) DO SET LOG=%%i
63
64
65%PYTHON% "%HOOKS_DIR%\trac-pre-commit-hook" "%TRAC_ENV%" "%LOG%" || exit 1