Edgewall Software

Ticket #1602: post-commit.0.9.cmd

File post-commit.0.9.cmd, 2.1 KB (added by jay@…, 2 years ago)

Works with 0.9 stable standard Trac hooks source:branches/0.9-stable/contrib/

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