| 1 | 12,13d11 |
|---|
| 2 | < # LINUX: |
|---|
| 3 | < # |
|---|
| 4 | 20,46d17 |
|---|
| 5 | < # WINDOWS: sample of pre-commit.bat (must use temporary files for the log message) |
|---|
| 6 | < # |
|---|
| 7 | < ##SET REPOS=%1 |
|---|
| 8 | < ##SET TXN=%2 |
|---|
| 9 | < ## |
|---|
| 10 | < ##::----------------------------- |
|---|
| 11 | < ##::Call the TRAC pre-commit hook |
|---|
| 12 | < ##:: |
|---|
| 13 | < ##SET TRAC_ENV=C:\somewhere\trac\project |
|---|
| 14 | < ##SET LOG_FILE=%TEMP%.\svnfileT-%TXN% |
|---|
| 15 | < ## |
|---|
| 16 | < ##svnlook log -t %TXN% %REPOS%>%LOG_FILE% |
|---|
| 17 | < ## |
|---|
| 18 | < ##python [trac-path]\contrib\trac-pre-commit-hook "%TRAC_ENV%" "file:%LOG_FILE%" |
|---|
| 19 | < ##IF ERRORLEVEL 1 SET TRAC_CANCEL=YES |
|---|
| 20 | < ##DEL %LOG_FILE% |
|---|
| 21 | < ##IF DEFINED TRAC_CANCEL GOTO :ERROR |
|---|
| 22 | < ##:: |
|---|
| 23 | < ##::----------------------------- |
|---|
| 24 | < ## |
|---|
| 25 | < ##:SUCCESS |
|---|
| 26 | < ##EXIT 0 |
|---|
| 27 | < ## |
|---|
| 28 | < ##:ERROR |
|---|
| 29 | < ##EXIT 1 |
|---|
| 30 | < ## |
|---|
| 31 | < |
|---|
| 32 | 59d29 |
|---|
| 33 | < log = _readFromFile( log ) |
|---|
| 34 | 85,98d54 |
|---|
| 35 | < |
|---|
| 36 | < def _readFromFile(message): |
|---|
| 37 | < """ Ivan Melnychuk: SOLUTION FOR WINDOWS SYSTEMS: |
|---|
| 38 | < Windows does not support returning values from script. |
|---|
| 39 | < Therefore temporary files may be used to keep some information like commit message |
|---|
| 40 | < If the 'message' starts with 'file:', and the file with indicated name exists, then read the text message from the file rather then using the text directly |
|---|
| 41 | < Even though actual message also may start with such prefix, it is very unlikely that the file exists with such a name by accident |
|---|
| 42 | < """ |
|---|
| 43 | < if message[:5] == 'file:' and os.path.exists( message[5:] ): |
|---|
| 44 | < f = open( message[5:], 'r' ) |
|---|
| 45 | < message = f.read() |
|---|
| 46 | < f.close() |
|---|
| 47 | < return message |
|---|
| 48 | < return message; |
|---|