Edgewall Software

Ticket #897: post-commit.cmd

File post-commit.cmd, 1.9 KB (added by nir.mor@…, 7 years ago)

post-commit.cmd fow windows hook (no need to change any thing in trac)

Line 
1@ECHO OFF
2REM POST-COMMIT HOOK
3REM
4REM The post-commit hook is invoked after a commit.  Subversion runs
5REM this hook by invoking a program (script, executable, binary, etc.)
6REM named 'post-commit' (for which this file is a template) with the
7REM following ordered arguments:
8REM
9REM   [1] REPOS-PATH   (the path to this repository)
10REM   [2] REV          (the number of the revision just committed)
11REM
12REM The default working directory for the invocation is undefined, so
13REM the program should set one explicitly if it cares.
14REM
15REM Because the commit has already completed and cannot be undone,
16REM the exit code of the hook program is ignored.  The hook program
17REM can use the 'svnlook' utility to help it examine the
18REM newly-committed tree.
19REM
20REM On a Unix system, the normal procedure is to have 'post-commit'
21REM invoke other programs to do the real work, though it may do the
22REM work itself too.
23REM
24REM Note that 'post-commit' must be executable by the user(s) who will
25REM invoke it (typically the user httpd runs as), and that user must
26REM have filesystem-level permission to access the repository.
27REM
28REM On a Windows system, you should name the hook program
29REM 'post-commit.bat' or 'post-commit.exe',
30REM but the basic idea is the same.
31REM
32REM Here is an example hook script, for a Windows CMD.exe interpreter:
33
34SET REPOS=%1
35SET TXN=%2
36
37SET SVN_DIR=C:\Program Files\Subversion
38SET PYTHON_DIR=C:\Program Files\Python23
39SET HOOKS_DIR=C:\... your hook folder in the repository ...\hooks
40SET TRAC_ENV=C:\... your trac folder ...\trac.db
41
42SET PYTHON="%PYTHON_DIR%\python.exe"
43SET SVN="%SVN_DIR%\bin\svn.exe"
44SET SVNADMIN="%SVN_DIR%\bin\svnadmin.exe"
45SET SVNLOOK="%SVN_DIR%\bin\svnlook.exe"
46
47FOR /F "usebackq delims==" %%i IN (`%%SVNLOOK%% log -r %TXN% %REPOS%`) DO SET LOG=%%i
48FOR /F "usebackq delims==" %%i IN (`%%SVNLOOK%% author -r %TXN% %REPOS%`) DO SET AUTHOR=%%i
49
50%PYTHON% "%HOOKS_DIR%\trac-post-commit-hook" -p "%TRAC_ENV%" -r "%TXN%" -u "%AUTHOR%" -m "%LOG%"